【发布时间】:2014-11-13 21:08:42
【问题描述】:
我可以在带有 Release (NDEBUG) 设置的 Visual C++ 2008 中做到这一点:
debug.h
#ifdef _DEBUG
void debug_printf(const char* format, ...);
#else
#define debug_printf(format, v) __noop
#endif
debug.cpp
#include "stdafx.h" //#include "debug.h" is inside it
void debug_printf(const char* format, ...) {
//so much work here
}
但在 Visual C++ 2013 中不再存在,我会在 debug.cpp 文件中得到编译错误。看来我必须更改 debug.h 中的定义策略。但我想知道是否有编译器设置可以重新启用旧方式?
【问题讨论】:
-
什么编译错误?为什么人们认为不发布它会有用?!
-
报错信息很多:缺少';' {之前,出乎意料的类型bla2...这样,是因为debug.cpp中的
debug_printf文本被替换为__noop,所以变成:void __noop(const char* format, ...) {
标签: c++ visual-studio-2013 visual-studio-2008 c-preprocessor compiler-flags