且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据 Visual Studio 中的调试/发布配置自动#defines

更新时间:2023-01-02 19:58:16

Visual Studio 自动为调试版本定义 _DEBUG 符号(以及用于非调试版本的 NDEBUG).

The Visual Studio automatically defines _DEBUG symbol for Debug builds (and NDEBUG for non-debug builds).

另一种方法是进入项目设置 -> 配置属性 -> C/C++ -> 预处理器,手动编辑预处理器定义.

Another way to do this is to go to the project settings -> configuration properties -> C/C++ -> preprocessor, and edit the preprocessor definitions manually.

另见:
这个答案更详细地解释了 _DEBUG 和 NDEBUG 之间的区别.
这个答案解释了 NDEBUG 符号的用途以及它是否由标准定义.

See also:
This answer explains the differences between _DEBUG and NDEBUG in more detail.
This answer explains the purpose of the NDEBUG symbol and whether or not is it defined by the standard.