「開発中にデバッグログを出力したい。でもリリース時には出力したくない」、というような要求はかなりの頻度である。 こんな感じでやることになるだろう(デバッグとリリースを切り分ける #ifdef は省略)。 #include <stdio.h> #include <stdarg.h> #define debug1(fmt, ...) printf("%s(%d):" fmt, __func__, __LINE__, __VA_ARGS__) #define debug2(arg) do { printf("%s(%d):", __func__, __LINE__), printf arg; } while (0) int debug3(const char *fmt, ...) { int rc; va_list va; va_start(va, fmt); rc = vprintf(fmt,