gcc -D defines a macro to be used by the preprocessor.
Syntax
$ gcc -Dname [options] [source files] [
-o output file]$ gcc -Dname=definition [options] [
source files] [-o output file]
Example
Write source file myfile.c:
// myfile.c #include
void main() {
#ifdef DEBUG printf("Debug run\n"); #else printf("Release run\n"); #endif }
Build myfile.c and run it with DEBUG defined:
$ gcc -D DEBUG myfile.c -o myfile $ ./myfile Debug run $
Or build myfile.c and run it without DEBUG defined:
$ gcc myfile.c -o myfile $ ./myfile Release run $