如何在Code :: Blocks中设置预定义的宏 [英] How to set predefined macros in Code::Blocks

查看:365
本文介绍了如何在Code :: Blocks中设置预定义的宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为本地安装Code :: Blocks设置一些预定义的宏.

Is there a way to set some predefined Macros for my local installation of Code::Blocks.

要详细说明,基本上我想让某些块仅在pc上编译,而不要在我将代码发送到的任何地方编译.实现此目的的一种方法如下:

To elaborate on that, basically I would like to have certain blocks compiled only at pc and not anyplace I send the code to. One way to achieve this is as follows:

#define MYPC
#ifdef MYPC
 //do something
#else
 // do something else
#endif

我本来可以实现相同的目的,但是我不想包含#define MYPC这一行,并且希望将其添加到IDE中的某个位置.我知道如何在Visual Studio中执行此操作,并且我认为它也存在于Code :: Blocks中. 谢谢.

I was to achieve the same thing, but I don't want to include the line #define MYPC and woud like to add this somewhere in the IDE. I know how to do this in Visual Studio, and I think it also exists in Code::Blocks as well. Thanks.

推荐答案

项目-属性-项目的生成选项-编译器设置-#defines.

Project - Properties - Project's build options - Compiler Settings - #defines.

编辑. #defines编辑框的示例:

Edit. Example of #defines edit box:


CONSTANT1
CONSTANT2="0"

给出以下命令行:

g ++ -DCONSTANT1 -DCONSTANT2 ="0" ...

g++ -DCONSTANT1 -DCONSTANT2="0" ...

这篇关于如何在Code :: Blocks中设置预定义的宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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