问题描述
应该使用哪个预处理器定义来指定代码的调试部分?
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设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)