应该使用哪个预处理器定义来指定代码的调试部分?
Which preprocessor define should be used to specify debug sections of code?
使用 #ifdef _DEBUG 或 #ifndef NDEBUG 或者有更好的方法来做到这一点,例如#define MY_DEBUG?
Use #ifdef _DEBUG or #ifndef NDEBUG or is there a better way to do it, e.g. #define MY_DEBUG?
我认为 _DEBUG 是特定于 Visual Studio 的,是 NDEBUG 标准吗?
I think _DEBUG is Visual Studio specific, is NDEBUG standard?
Visual Studio 定义 _DEBUG 当您指定 /MTd 或 /MDd> 选项,NDEBUG 禁用标准 C 断言.在适当的时候使用它们,即 _DEBUG 如果您希望您的调试代码与 MS CRT 调试技术 和 NDEBUG 如果你想和 assert() 保持一致.
Visual Studio defines _DEBUG when you specify the /MTd or /MDd option, NDEBUG disables standard-C assertions. Use them when appropriate, ie _DEBUG if you want your debugging code to be consistent with the MS CRT debugging techniques and NDEBUG if you want to be consistent with assert().
如果您定义自己的调试宏(并且您不会破解编译器或 C 运行时),请避免以下划线开头的名称,因为这些是保留的.
If you define your own debugging macros (and you don't hack the compiler or C runtime), avoid starting names with an underscore, as these are reserved.
这篇关于_DEBUG 与 NDEBUG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
为什么两个函数的地址相同?Why do two functions have the same address?(为什么两个函数的地址相同?)
为什么 std::function 的初始化程序必须是可复制构Why the initializer of std::function has to be CopyConstructible?(为什么 std::function 的初始化程序必须是可复制构造的?)
混合模板与多态性mixing templates with polymorphism(混合模板与多态性)
我什么时候应该使用关键字“typename"?使用模When should I use the keyword quot;typenamequot; when using templates(我什么时候应该使用关键字“typename?使用模板时)
依赖名称解析命名空间 std/标准库Dependent name resolution amp; namespace std / Standard Library(依赖名称解析命名空间 std/标准库)
gcc 可以编译可变参数模板,而 clang 不能gcc can compile a variadic template while clang cannot(gcc 可以编译可变参数模板,而 clang 不能)