gcc -D 옵션 플래그

gcc -D는 전처리기에서 사용할 매크로를 정의합니다.

통사론

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

소스 파일 myfile.c 쓰기 :

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

 

myfile.c 를 빌드하고 정의된 DEBUG로 실행합니다.

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

 

또는 myfile.c 를 빌드하고 DEBUG를 정의하지 않고 실행합니다.

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

 


또한보십시오

Advertising

GCC
°• CmtoInchesConvert.com •°