You cannot forward an enum declaration in C ++ , but you can in C.
For a C code base that uses some C ++ code, is there a way to use the declared cast in C that does not cause errors if this header is used in C ++ (in a block extern "C" {..})?
Example:
extern "C" {
enum MyEnum;
}
int main() { return 0; }
GCC gives an error:
error: use of enum ‘MyEnum’ without previous declaration
enum MyEnum;
^~~~~~
Clang also fails:
error: ISO C++ forbids forward references to 'enum' types
enum MyEnum;
To give some context, it is mainly a C base, where a small C ++ module includes a header for C code. I can hack a bit so that C ++ ignores the enumeration, but would like to know if C ++ can use C headers in this case.
: , C , , , - : GCC/CLANG/MSVC.