944,081 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5675
  • C++ RSS
Oct 27th, 2004
0

Preprocessor definitions on the command line

Expand Post »
Hi, I need to have my compiler take preprocessor definitions from the
command line. How does it differ from normal command line parameter passing (main(int arc, char *argv[])) ?
Thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ejptccs123 is offline Offline
2 posts
since Oct 2004
Oct 27th, 2004
0

Re: Preprocessor definitions on the command line

It depends on the compiler; you'll usually see things like -D<symbol> or \D<symbol>. Look it up in your documentation.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Nov 3rd, 2004
0

Re: Preprocessor definitions on the command line

Thanks for the tip. I'm using Dev-C++. And I got the preprocessor flag to work.
Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ejptccs123 is offline Offline
2 posts
since Oct 2004
Jul 18th, 2007
-2

Re: Preprocessor definitions on the command line

i need it fast
Click to Expand / Collapse  Quote originally posted by ejptccs123 ...
Hi, I need to have my compiler take preprocessor definitions from the
command line. How does it differ from normal command line parameter passing (main(int arc, char *argv[])) ?
Thanks.
Reputation Points: 8
Solved Threads: 0
Newbie Poster
paramaguru is offline Offline
1 posts
since Nov 2006
Jul 18th, 2007
0

Re: Preprocessor definitions on the command line

1. g++ -DHAVE_CONFIG -Wall -std=c++98 -o myprogram
2. ,/myprogram hello world

in 1., the command line args are used by the c preprocessor, some are forwarded to the compiler and linker

in 2., the command line args are passed to myprogram and are available as parameters passed to main
Last edited by vijayan121; Jul 18th, 2007 at 9:53 am.
Reputation Points: 1159
Solved Threads: 285
Posting Virtuoso
vijayan121 is offline Offline
1,606 posts
since Dec 2006
Jul 20th, 2007
0

Re: Preprocessor definitions on the command line

preprocessor directives/macros are processed at the time of compilation. Arguments relevant to preprocessor (e.g. -DXXX=value) are passed to compiler and used by compiler. Any argument passed on command line is called command line arguments. . So these are the CLI args to compiler.
After compilation (and linking) the executable of your program is ready.. when you call/execute this executable with CLI args, these would go to main() and will be be available to your program.
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: GetTextExtentPoint32 API
Next Thread in C++ Forum Timeline: How do i output the contents of the stack with the functions Output ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC