gcc -D parinkties vėliavėlė

gcc -D apibrėžia makrokomandą, kurią turi naudoti išankstinis procesorius.

Sintaksė

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

Pavyzdys

Parašykite šaltinio failą myfile.c :

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

 

Sukurkite myfile.c ir paleiskite ją su apibrėžtu DEBUG:

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

 

Arba sukurkite myfile.c ir paleiskite jį neapibrėžę DEBUG:

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

 


Taip pat žr

Advertising

GCC
°• CmtoInchesConvert.com •°