indicador de opción gcc -D

gcc -D define una macro para ser utilizada por el preprocesador.

Sintaxis

$ gcc -Dname [options] [source files] [-o output file]
$ gcc -Dname=definition [options] [source files] [-o output file]

Ejemplo

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
$

 


Ver también

Advertising

CCG
°• CmtoInchesConvert.com •°