0

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.

5
Contributors
5
Replies
6
Views
12 Years
Discussion Span
Last Post by thekashyap
0

It depends on the compiler; you'll usually see things like -D<symbol> or \D<symbol>. Look it up in your documentation.

0

Thanks for the tip. I'm using Dev-C++. And I got the preprocessor flag to work.
Thanks.

-2

i need it fast

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.

Votes + Comments
Rude
Digging up a thread from 3 years ago
0

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

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.