简体   繁体   English

通过 -include gcc 标志让 Eclipse 知道包含的文件

[英]Let Eclipse know files included via -include gcc flag

I need to include a configuration header file (config.h), containing system-wise defines.我需要包含一个配置头文件 (config.h),其中包含系统定义。 Instead of including it in every source file, I used the -include gcc flag, like so:我没有将它包含在每个源文件中,而是使用了 -include gcc 标志,如下所示:

-include src/config.h

This works as expected, however Eclipse does not know that config.h is indeed included in every source file, so, whenever a block like this is present:这按预期工作,但是 Eclipse 不知道 config.h 确实包含在每个源文件中,因此,每当出现这样的块时:

#ifdef MACRO_DEFINED_IN_CONFIG_H
// Code block
#endif

everything is greyed-out.一切都变灰了。

Is there a workaround for this?有解决方法吗? Thank you.谢谢你。

You need to have those definitions in the project properties:您需要在项目属性中有这些定义:

在此处输入图片说明

not in the file.不在文件中。 Then eclipse will call the gcc wirh the -D.... s然后 eclipse 将调用 gcc wirh -D.... s

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM