Skip to content

Instantly share code, notes, and snippets.

@yihangho
Last active December 17, 2015 03:59
Show Gist options
  • Save yihangho/5547366 to your computer and use it in GitHub Desktop.
Save yihangho/5547366 to your computer and use it in GitHub Desktop.
#ifdef DEBUG
#define debug printf("Debug: ");printf
#else
#define debug //
#endif
#include <cstdio>
int main()
{
debug("Hello World!\n");
return 0;
}
//Use debug function like printf
//To show debugging messages, compile with -DDEBUG flag, eg, g++ main.cpp -o main.out -O2 -DDEBUG
//To hide debugging messages, compile without -DDEBUG flag, eg, g++ main.cpp -o main.out -O2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment