_DEBUG vs NDEBUG [英] _DEBUG vs NDEBUG

查看:239
本文介绍了_DEBUG vs NDEBUG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该使用哪个预处理器定义来指定代码的调试部分?



使用 #ifdef _DEBUG #ifndef NDEBUG 或者有更好的方法来做,例如 #define MY_DEBUG



我认为 _DEBUG 是Visual Studio特定的是NDEBUG标准?

解决方案

Visual Studio定义 _DEBUG 您指定 / MTd / MDd 选项, NDEBUG 禁用标准C断言。如果您希望调试代码与 _DEBUG 库/ zh712wwf%28VS.80%29.aspxrel =noreferrer> MS CRT调试技术 NDEBUG 如果要与 assert()



如果您定义自己的调试宏(而且您不会破解编译器或C运行时)避免使用下划线启动名称,因为这些保留。


Which preprocessor define should be used to specify debug sections of code?

Use #ifdef _DEBUG or #ifndef NDEBUG or is there a better way to do it, e.g. #define MY_DEBUG?

I think _DEBUG is Visual Studio specific, is NDEBUG standard?

解决方案

Visual Studio defines _DEBUG when you specify the /MTd or /MDd option, NDEBUG disables standard-C assertions. Use them when apropriate, 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().

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 vs NDEBUG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆