_DEBUG VS NDEBUG [英] _DEBUG vs NDEBUG

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

问题描述

其中preprocessor定义应该使用指定code的调试节?

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断言。 apropriate时使用它们,即 _DEBUG 如果你希望你的调试code是一致的的 MS CRT调试技术 NDEBUG 如果你想成为一致断言()

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().

如果你定义自己的调试宏(你不砍编译器或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 VS NDEBUG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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