Eclipse CDT parser support for C++11?

2019-05-24 11:17发布

I'm using Eclipse 3.7.2 with CDT 8.0.2 on Linux. How can I configure the CDT to recognize c++11 syntax, specifically override? Currently the parser flags a bogus error on the line indicated. The build completes without error since I include -std=c++11 in my compiler command lines.

class foo
{
public:
    foo(){}
    virtual ~foo(){}
    virtual void func(){}
};

class bar : public foo
{
public:
    bar(){}
    virtual ~bar(){}
    virtual void func() override {} // <--- parser incorrectly flags syntax error
};

int main()
{
    bar my_bar;
    return 0;
}

I tried the directions on the Eclipse wiki and here without success. Again, I only need the editor's parser to recognize c++11, the actual build is fine.

3条回答
做自己的国王
2楼-- · 2019-05-24 11:28

This problem solved itself for me when I installed the development version of eclipse:

Eclipse Luna 4.4 CDT 8.4

查看更多
Animai°情兽
3楼-- · 2019-05-24 11:34

To fix C++11 syntax highlighting go to:

Project Properties --> C/C++ General --> Paths and Symbols --> Symbols --> GNU C++

and overwrite the symbol (i.e. add new symbol):

__cplusplus

with value

201103L

Make sure that indexer is enabled in project settings (C/C++ general --> Indexer)

Then reindex (Project --> C/C++ Index --> Rebuild)

if the problem still persist reindex once again. It should work now.

查看更多
地球回转人心会变
4楼-- · 2019-05-24 11:38

You can manually define a override macro with no content for the parser only in your Project "Properties/Preprocessor Includes/CDT User Settings".

查看更多
登录 后发表回答