Eclipse CDT parser support for C++11?

爷,独闯天下 提交于 2019-12-08 01:44:47

问题


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.


回答1:


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.




回答2:


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




回答3:


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

Eclipse Luna 4.4 CDT 8.4



来源:https://stackoverflow.com/questions/13591020/eclipse-cdt-parser-support-for-c11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!