Skip to content

Instantly share code, notes, and snippets.

@aakbar5
Last active July 19, 2016 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aakbar5/bed181f4875bb9e90ab2c491c40c2ff6 to your computer and use it in GitHub Desktop.
Save aakbar5/bed181f4875bb9e90ab2c491c40c2ff6 to your computer and use it in GitHub Desktop.
enum as bitfield
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