Last active
July 19, 2016 09:26
-
-
Save aakbar5/bed181f4875bb9e90ab2c491c40c2ff6 to your computer and use it in GitHub Desktop.
enum as bitfield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By default enum can't be as bitfield | |
typedef enum _type_ { | |
CAT = 0, | |
DOG, | |
UNKNOWN | |
} TYPE; | |
typedef struct _animal { | |
TYPE type : 2; | |
}; | |
GCC ((Sourcery CodeBench 2015.17-10) 5.2.0) will show error "width of 'type' exceeds its type" | |
Use -fno-short-enums to get rid of this. Details: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0774b/chr1411640303038.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment