gcc -D define una macro para ser utilizada por el preprocesador.
$ gcc -Dname [options] [source files]
[-o output file]
$ gcc -Dname=definition [options]
[source files] [-o output file]
Escriba el archivo fuente myfile.c :
// myfile.c
#include <stdio.h>
void main()
{
#ifdef DEBUG
printf("Debug run\n");
#else
printf("Release run\n");
#endif
}
Cree myfile.c y ejecútelo con DEBUG definido:
$ gcc -D DEBUG myfile.c -o myfile
$ ./myfile
Debug run
$
O crea myfile.c y ejecútalo sin DEBUG definido:
$ gcc myfile.c -o myfile
$ ./myfile
Release run
$