In a makefile I work on, gcc is used with the -D XOPEN_SOURCE=500 and -D_BSD_SOURCE options. gcc --help does not tell me what these are; a quick google search didn’t help either. I’m quite a newbie with gcc, could someone give me a hint?
In a makefile I work on, gcc is used with the -D XOPEN_SOURCE=500 and
Share
According to the GCC documentation (“3.11 Options Controlling the Preprocessor”), the
-Dswitch defines the macrosXOPEN_SOURCEand_BSD_SOURCEwith the values500and1respectively. It’s as though you have this code at the beginning of all the source files you pass to GCC:Build scripts usually take advantage of the compiler’s ability to “insert” macros like these to “communicate” to the source code details about the platform being targeted (e.g. operating system version).
The “opposite” command-line switch for
-Dis-U, which#undefs a macro.Most (if not all) modern C/C++ compilers include similar switches. For example, Visual C++ compilers accept the
/Dcompiler switch, which essentially serves the same purpose as GCC’s-Dswitch.For future reference, the GCC option index is great if you need to look up compiler switches for the GCC compiler.