I've been happily compiling my code with GCC without issue for the past three months until I rebuilt my cross-compiler, which was when I found myself getting the message "error: bit-field '...' with non-integral type".
An example of an offending enum is below:
typedef unsigned char byte;
enum class opStatus : byte
{
/* Process has yet to begin execution */
Ready,
/* Process can resume execution */
Started,
/* Process has completed */
Finished,
/* Process is handling shutdown */
Finishing,
};
struct // Example usage
{
opStatus Status : 2;
};
Why is this happening?
struct { opStatus Status : 2; };will give compilation error anyway even ifopStatus Status : 2is allowed in the language! You must introduce at least one name in the declaration. So writestruct tag_name { opStatus Status : 2; };orstruct { opStatus Status : 2; } object_name;.