[makefile]


CPPFLAGS+=-D_DEBUG -O0 -g


all : debug_test


clean:

rm -rf debug_test

rm -rf debug_test.exe

rm -rf *.o




[debug_test.cpp]

#include <stdio.h>

int main()
{
#ifdef _DEBUG
  printf("debug\n");
#else
  printf("release\n");
#endif // _DEBUG
  return 0;
}




[result]

$ make
g++  -D_DEBUG -O0 -g   debug_test.cpp   -o debug_test

$ ./debug_test.exe
debug




[download]