简体   繁体   中英

Netbeans Highlights errors where are no errors

I use NetBeans with the C++ Plugin (Version 8.0.2). I have one class called "Settings", which gives me a huge amount of false errors, making it impossible to debug this class using NetBeans.

All errors begin here in the hpp file:

bool SetSettingString(std::string Name, std::string defaultValue, bool override = true);
bool SetSettingFloat(std::string Name, float defaultValue, bool override = true);
bool SetSettingInt(std::string Name, int defaultValue, bool override = true);
bool SetSettingBool(std::string Name, bool defaultValue, bool override = true);
bool SetSettingDouble(std::string Name, double defaultValue, bool override = true); 

The error starts at the first defaultValue , also in the cpp file exactly at this point, NetBeans highlights nearly all the code red, as he cant resolve any identifiers. The code is clean and compiles without even a warning.

My first guess was, that NetBeans interprets defaultValue somehow as a keyword, but changing it to another name wont change anything. I also found on SO the suggestion to clear the usercache, which I did (deleting the index directory under ~/.cache/netbeans/8.0.2/ ).

Has anyone any suggestion on how to fix this? Thanks in advance!

override is a keyword (only if used in proper context) since C++11 - it might confuse NetBeans.

It's not normal keyword (like for etc.) which can't be used as identifier - due to backward compatibility (with code like yours :) ), override will be treated as keyword only if it appears after method declaration:

void fun() override;

This code forces compiler to check if base class has virtual method fun .

So your code is correct, but simple IDE parsers checking for keywords might get lost. As this is only parameter name, I'd suggest changing it.

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