0

Is there a way to configure Eclipse so that it can resolve the following forward declaration example?
This builds without any problems.

class MyClass {
public:
  enum class MyEnum; // Forward declaration.
  enum class MyOtherEnum {
    DELTA,
    ECHO,
    FOXTROT
  };
};

enum class MyClass::MyEnum{
  ALPHA,
  BRAVO,
  CHARLIE
};

int main(void) {
  volatile MyClass::MyEnum myVariable = MyClass::MyEnum::BRAVO; // Flags up two semantic errors.
  volatile MyClass::MyOtherEnum myOtherVariable = MyClass::MyOtherEnum::ECHO; // No problems.
  return 0;
}

Semantic Errors:
Symbol 'BRAVO' could not be resolved.
Type 'MyClass::MyEnum' could not be resolved.

Using Eclipse CDT Mars.2 Release (4.5.2).

matt.baker
  • 232
  • 1
  • 9
  • Because Eclipse wants to be too clever... It analyses the code itself instead of letting the compiler do the job. So you must be sure to set the correct C++ level in Eclipse (C++ 98, 11, 14, ...). If it is not enough either throw Eclipse away, or fully define MyEnum inside the class... – Serge Ballesta Mar 24 '16 at 15:43
  • @SergeBallesta thanks for the information. I just tried setting the version using the process outlined here: http://stackoverflow.com/questions/13635079/enable-c11-in-eclipse-cdt-juno-kepler-luna-indexer, but no luck unfortunately. I guess they overlooked enums as it works with nested structs and classes. – matt.baker Mar 26 '16 at 12:38

1 Answers1

0

This is a known bug and is fixed in the upcoming Neon release of Eclipse CDT.

Duplicate Bug report

matt.baker
  • 232
  • 1
  • 9