C / C ++:可移植的方法来检测调试/释放? [英] C / C++ : Portable way to detect debug / release?
本文介绍了C / C ++:可移植的方法来检测调试/释放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个标准化的(例如,通过所有主要的编译器实现)的#define,让我来调试和释放区分建立?
Is there a standardized (e.g. implemented by all major compilers) #define that will allow me to distinguish between debug and release builds?
推荐答案
如果相信
#ifdef NDEBUG
// nondebug
#else
// debug code
#endif
是最便携的。
不过的没有的编译器知道你是否编译调试或释放,所以这是不是自动的。但是这一次是由C运行时使用ASSERT.H,所以这是很常见的。 Visual Studio将设置它,我敢肯定,大多数其他IDE的意志为好。
But no compiler knows whether you are compiling debug or release, so this isn't automatic. But this one is used by assert.h in the c-runtime, so it's quite common. Visual Studio will set it, and I'm sure most other IDE's will as well.
这篇关于C / C ++:可移植的方法来检测调试/释放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文