Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created August 21, 2012 13:19
Show Gist options
  • Select an option

  • Save qnighy/3415316 to your computer and use it in GitHub Desktop.

Select an option

Save qnighy/3415316 to your computer and use it in GitHub Desktop.
よくあるデバッグ用マクロ
// #define DEBUG
#ifdef DEBUG
#define dprintf(format, ...) fprintf(stderr, format, __VA_ARGS__)
// #define dprintf(format, ...) do{ fprintf(stderr, format, __VA_ARGS__); fflush(stderr); } while(0)
// 後者はfflushも同時に行うバージョン
#else
#define dprintf(format, ...)
#endif
// 注意事項
// forループを使ってデバッグ出力をしている場合、forループ自体は消滅しない
// forループの存在によって処理時間が大幅に削られることが予想される場合、そのforループを#ifdef DEBUGで囲うなどの対処が必要
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment