简体   繁体   中英

Let Eclipse know files included via -include gcc flag

I need to include a configuration header file (config.h), containing system-wise defines. Instead of including it in every source file, I used the -include gcc flag, like so:

-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:

#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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