typedef enum BeNeLux
{
BELGIUM,
NETHERLANDS,
LUXEMBURG
} _ASSOCIATIONS_ BeNeLux;
When I try to compile this with C++ Compiler, I am getting errors, but it seems to work fine with a C compiler. So here's the question. Is it possible to pack an enum in C++, or can someone see why I would get the error?
The error is:
"semicolon missing after declaration of BeNeLux".
I know, after checking and rechecking, that there definitely is a semicolon there, and in any places required in the rest of the code.
Addendum:
_PACKAGE_
was just an example. I am renaming it.
_ASSOCIATIONS_
is not a type of BeNeLux:
#define _ASSOCIATIONS_ __attribute__((packed))
The code is iffed, but only to make sure it is GNU C/C++.
#if defined (__GNUC__)
#define _ASSOCIATIONS_ __attribute__((packed))
#else
#define _ASSOCIATIONS_
Would this cause problems? I thought (GNUC) worked for both C and C++
Addendum 2:
I even tried
#ifdef __cplusplus
extern "C" {
#endif
typedef enum BeNeLux
{
BELGIUM,
NETHERLANDS,
LUXEMBURG
} _ASSOCIATIONS_ BeNeLux;
#ifdef __cplusplus
}
#endif
No joy. Anyone?
Note: -fshort-enums is not a possibility; looking for a programmatic solution.
_PACK_
and_PACKAGE_
are illegal as user-defined macro names. Names beginning with underscore(s) are basically reserved for compiler's internal identifiers and standard library implementations. (The rules are more complicated, but just don't use leading underscores.) – Octennial