我如何才能说服Eclipse CDT定义了用于源代码编辑和代码完成的宏? [英] How can I convince Eclipse CDT that a macro is defined for source code editing and code completion?
问题描述
我的源代码中有
// foo.cpp
struct foo
{
foo() {}
#ifdef I_WANT_THIS_FEATURE
void bar() {}
#endif
};
我的Makefile中有
In my Makefile I have
foo.o: foo.cpp
g++ -c -DI_WANT_THIS_FEATURE foo.cpp -o foo.o
这可以从命令行以及我在Eclipse中创建的外部构建器(基本上定义了一些环境变量并调用 make
)进行编译,而我可以调用 foo:: bar()
.
This compiles fine from the command line as well as with the external builder that I have created in Eclipse (which basically defines a few environment variables and calls make
) and I can call foo::bar()
.
但是,在Eclipse CDT源代码编辑器中,我定义 foo :: bar()
的部分具有灰色背景(建议 foo :: bar()
>不会包含在构建中),并且对 foo
类型的对象的代码完成不建议使用 bar()
作为可以调用的方法.
However, in the Eclipse CDT source code editor, the part where I define foo::bar()
has a grey background (suggesting that foo::bar()
would not be included in the build) and code completion on objects of type foo
does not suggest bar()
as a method that can be called.
如何在带有自定义makefile的Eclipse CDT makefile项目中定义 I_WANT_THIS_FEATURE
宏,以便源代码编辑器和代码完成可以识别该宏?
How can I define the I_WANT_THIS_FEATURE
macro in an Eclipse CDT makefile project with custom makefile so that it is known to the source code editor and the code completion?
推荐答案
找到了它:项目->属性-> C/C ++常规->路径和符号
Found it: Project -> Properties -> C/C++ General -> Paths and Symbols
选择符号标签,并添加... 具有名称 I_WANT_THIS_FEATURE
和的新符号>值为 1
.
Choose the Symbols tab and Add... a new Symbol with Name I_WANT_THIS_FEATURE
and a Value of 1
.
这篇关于我如何才能说服Eclipse CDT定义了用于源代码编辑和代码完成的宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!