How to set predefined macros in Code::Blocks

China☆狼群 提交于 2019-12-23 07:50:02

问题


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.


回答1:


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" ...



来源:https://stackoverflow.com/questions/4067246/how-to-set-predefined-macros-in-codeblocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!