2

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.

Community
  • 1
  • 1
srking
  • 4,512
  • 1
  • 30
  • 46

3 Answers3

5

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.

selyunin
  • 1,530
  • 2
  • 23
  • 30
0

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

Gunther Piez
  • 29,760
  • 6
  • 71
  • 103
0

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

Eclipse Luna 4.4 CDT 8.4

Galik
  • 47,303
  • 4
  • 80
  • 117