如何在 Code::Blocks 中设置预定义宏

发布于 2024-09-30 10:04:43 字数 333 浏览 0 评论 0原文

有没有办法为我本地安装的 Code::Blocks 设置一些预定义的宏。

为了详细说明这一点,基本上我希望仅在电脑上编译某些块,而不是在我将代码发送到的任何地方编译。实现此目的的一种方法如下:

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

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

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极度宠爱 2024-10-07 10:04:43

项目 - 属性 - 项目的构建选项 - 编译器设置 - #defines。

编辑。 #defines 编辑框示例:

CONSTANT1
CONSTANT2="0"

给出以下命令行:

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

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

Edit. Example of #defines edit box:

CONSTANT1
CONSTANT2="0"

Gives the following command line:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文