Preprocessor definitions on the command line

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 2
Reputation: ejptccs123 is an unknown quantity at this point 
Solved Threads: 0
ejptccs123 ejptccs123 is offline Offline
Newbie Poster

Preprocessor definitions on the command line

 
0
  #1
Oct 27th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,630
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 718
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Preprocessor definitions on the command line

 
0
  #2
Oct 27th, 2004
It depends on the compiler; you'll usually see things like -D<symbol> or \D<symbol>. Look it up in your documentation.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 2
Reputation: ejptccs123 is an unknown quantity at this point 
Solved Threads: 0
ejptccs123 ejptccs123 is offline Offline
Newbie Poster

Re: Preprocessor definitions on the command line

 
0
  #3
Nov 3rd, 2004
Thanks for the tip. I'm using Dev-C++. And I got the preprocessor flag to work.
Thanks.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 1
Reputation: paramaguru is an unknown quantity at this point 
Solved Threads: 0
paramaguru paramaguru is offline Offline
Newbie Poster

Re: Preprocessor definitions on the command line

 
-2
  #4
Jul 18th, 2007
i need it fast
Originally Posted by ejptccs123 View 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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: Preprocessor definitions on the command line

 
0
  #5
Jul 18th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Preprocessor definitions on the command line

 
0
  #6
Jul 20th, 2007
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.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC