代码块调试预处理器 [英] Codeblocks debug preprocessor

查看:49
本文介绍了代码块调试预处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写带有代码块的C ++程序,出于调试目的,我需要知道代码块的构建目标是否设置为 DEBUG或 RELEASE。

I'm writing a C++ Program with Codeblocks and for debugging-purposes I need to know if the Building-Target of Codeblocks is set to "DEBUG" or to "RELEASE".

我已经尝试过:

#ifdef DEBUG
    printf("Debug-Message");
#endif

和此

#ifdef _DEBUG
    printf("Debug-Message");
#endif

但是这些词都没有定义。
我每次更改建筑目标时是否必须自己定义调试并进行更改,还是有一个我不知道的词?

But none of this words are defined. Do I have to define DEBUG on my own and change it, everytime I change the Building-Target, or is there a word I don't know?

推荐答案


我每次都要更改
Building-Target时是否必须自己定义DEBUG并进行更改?

Do I have to define DEBUG on my own and change it, everytime I change the Building-Target, or is there a word I don't know?

我不知道什么,如果Code :: Blocks默认设置了任何内容。但是,如果您定义自己的#defines

I don't know what, if anything is set by default by Code::Blocks. But, if you define your own #defines

Project->Build options...->[Debug|Release]->#defines 

在构建目标之间切换时,您不必更改它们(调试或发布)。它使您可以定义特定于Debug版本的值以及特定于Release版本的值。

you don't have to change them as you switch between build targets (DEBUG or RELEASE). It lets you define values that are specific to the Debug build, as well as values that are specific to the Release build.

为避免每次都要手动输入值,每个新项目,您都可以仅通过Debug / Release #defines定义一个小项目,然后将其保存为项目模板,然后从该项目模板创建新项目。

To avoid having to manually enter it each time for each new project you can make a small project with just your Debug/Release #defines and save that as a project template and then create new projects from that project template.

这篇关于代码块调试预处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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