Last active
August 29, 2017 02:10
-
-
Save lixingcong/bf9c4b2c0cc1d0f4e7396174d38473f2 to your computer and use it in GitHub Desktop.
debug output in MFC
This file contains 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
// use C source code, not macro | |
void debug_printf(char *fmt,...){ | |
#ifdef _DEBUG | |
va_list ap; | |
va_start(ap,fmt); // #include <stdarg.h> | |
vprintf(fmt,ap); | |
va_end(ap); | |
#endif | |
} | |
// or use the macro | |
// filename: debug.h | |
#if 0 | |
// 调试用,输出到windows屏幕终端 | |
#ifdef _DEBUG | |
#define debug_printf(fmt, ...) \ | |
do{ \ | |
_cprintf(fmt, __VA_ARGS__); \ | |
}while(0) | |
#else | |
#define debug_printf(fmt, ...) | |
#endif | |
#endif |
This file contains 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
#include "debug.h" | |
#ifdef _DEBUG | |
if(!AllocConsole()) // 创建调试console | |
AfxMessageBox(_T("Fail to creat the console!"),MB_ICONEXCLAMATION); | |
debug_printf("Hello, I am the debug console!\n"); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment