gcc -D opció jelzője

A gcc -D meghatároz egy makrót, amelyet az előfeldolgozó használ.

Szintaxis

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

Példa

Írja be a myfile.c forrásfájlt :

// myfile.c
#include <stdio.h>
 
void main()
{
    #ifdef DEBUG   
       printf("Debug run\n");
    #else
       printf("Release run\n");
    #endif
}

 

Építsd fel a myfile.c fájlt , és futtasd a DEBUG definícióval:

$ gcc -D DEBUG myfile.c -o myfile
$ ./myfile
Debug run
$

 

Vagy készítse el a myfile.c fájlt , és futtassa a DEBUG meghatározása nélkül:

$ gcc myfile.c -o myfile
$ ./myfile
Release run
$

 


Lásd még

Advertising

GCC
°• CmtoInchesConvert.com •°