개요
- GCC #ifdef DEBUG
- C언어 #ifdef DEBUG
#ifdef DEBUG~#endif사이의 코드는 디버깅시에만 실행하도록 한다.- gcc로 컴파일할 때
-DDEBUG옵션을 붙이면 디버깅하고, 옵션이 없으면 무시된다.
실습
- hello_debug.c
#include <stdio.h>
int main() {
#ifdef DEBUG
printf("DEBUG!!!!\n");
#endif
printf("Hello World\n");
return 0;
}
root@zetawiki:~# gcc hello_debug.c
root@zetawiki:~# ./a.out
Hello World
root@zetawiki:~# gcc hello_debug.c -DDEBUG
root@zetawiki:~# ./a.out
DEBUG!!!!
Hello World