简体   繁体   中英

Eclipse CDT graying out wrong part of code under #ifndef

I have header base.h containing

#ifndef GUARD_H
#define GUARD_H

<my code>

#endif

Eclipse CDT is graying out everything below #ifndef GUARD_H . This would be correct if GUARD_H were defined, but it is not. Actually, the only place where it is defined across my system is the following line, precisely as intended for an include guard. So, I cannot see why this happens.

Moreover, among the hundreds of headers I used under Eclipse CDT in my life, and in particular under the present project, this is the first time I see such a thing.

Why does this happen? How can I fix this?

Using Eclipse IDE for C/C++ Developers, Version: 2018-09 (4.9.0), Build id: 20180917-1800 under Win 10.

As per this comment , adding affected headers to Preferences -> C/C++ -> Indexer -> Index all variants of specific headers (separated by semicolon) helps. "Index all header variants" can also help but at a possible performance cost.

I found it sometimes works. Sometimes it doesn't, but it starts working at a later time while I am coding or navigating, without any apparent specific action on my side. Also the opposite, sometimes code becomes greyed out, without any apparent specific action on my side.

Found this serendipitously. Changing affected headers to something like

#ifndef GUARD_H
#define GUARD_H

<my code>

#endif // GUARD_H   <-- Modification

did the job in a few cases I tried.

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