by gpderetta · 4y ago · 0 comments
struct A;
enum B; // as you pointed out, not allowed by the C++ standard
// fine to declare, define, and invoke
void fooA(struct A*);
void fooB(enum B*);
// ok to forward declare, but you can't call them
void barA(struct A);
void barB(enum B); enum class A; // defaults to int
enum B :int;
enum C;
fooA(A);
FooB(B);
FooC(C);
fooA((A)0);
fooB((B)0);
fooC((C)0); // error
but indeed GCC refuses plain enum. Forward declaring enums in C is an old GCC extension that still deosn't allow to pass them when incomplete;Enums in GCC do always default to int or unsigned int, unless -fshot-enums is used which is ABI breaking.
Probably I was misremembering this combination of the int ABI and the forward declaring extension.