Created
August 21, 2012 13:19
-
-
Save qnighy/3415316 to your computer and use it in GitHub Desktop.
よくあるデバッグ用マクロ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // #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