C: An unfamiliar enum declaration
I'm attempting to study the source of mruby to learn C, and I came across this line:
enum mrb_vtype tt:8;
I actually have no clue at all what this means: I've never seen enum in this form. Any insight would be appreciated :)
Posted Jul 27, 2012, 7:25 AM UTC
12
It's not itself an enum - it is defining a member of a struct to be an instance of the mrb_vtype enum - the member will be called tt. The :8 at the end is a bitfield specifier - it says that the tt member must only take up 8 bits (i.e. a byte on most architectures). Whether this will actually save any space depends entirely on the mood of the C compiler.
I lol'd