运行时如何确定Visual Studio C ++中的调试或发布模式 [英] Runtime how to determine Debug or release mode in visual studio c++

查看:115
本文介绍了运行时如何确定Visual Studio C ++中的调试或发布模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做学校作业。在调试模式下,我想打开控制台模式,而在发行版中,我想关闭控制台。

I am doing my school assignment. During debug mode I would like to turn on my console mode and during release turn off console.

我尝试了stackoverflow中推荐的marco,但是它不起作用。我正在使用Visual Studio 2012(空项目C ++)

I have try marco as recommended in stackoverflow but it is not working. I am using visual studio 2012 (empty project c++)

#if DEBUG
 //doing something
#else
 //Release mode doing something
#endif


推荐答案

#if DEBUG 仅在通过编译器选项定义 DEBUG 时有效。

#if DEBUG will only work if you define DEBUG via the compiler options.

默认情况下,未定义 DEBUG ,但定义了 _DEBUG 。尝试 #if defined(_DEBUG),或更改编译器选项(通过项目属性/配置属性/ C / C ++ /预处理器/预处理器定义)以定义 DEBUG

By default, DEBUG is not defined, but _DEBUG is. Try #if defined(_DEBUG), or change your compiler options (via Project Properties / Configuration Properties / C/C++ / Preprocessor / Preprocessor Definitions) to define DEBUG.

这篇关于运行时如何确定Visual Studio C ++中的调试或发布模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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