#include <stdio.h> #define DEBUG #ifdef DEBUG #define dprintf(fmt, arg...) \ do { \ if (debug) \ printf("DEBUG: " fmt, ##arg); \ } while (0) #else #define dprintf(fmt, arg...) #endif int debug = 1; int main(int argc, char *argv[]) { dprintf("%s\n", "hello world"); return 0; }
執行結果 DEBUG: hello world
沒有留言:
張貼留言