gcc -D defines a macro to be used by the preprocessor.
$ gcc -Dname [options] [source files]
[-o output file]
$ gcc -Dname=definition [options]
[source files] [-o output file]
Write source file myfile.c:
// myfile.c
#include <stdio.h>
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
$