The protocol compiler just generates C++ code. How the enum is represented in memory is entirely up to your C++ compiler. The standard allows the compiler to choose the size of the enum (with the restriction that it should be not more than sizeof(int)). I would guess that a typical compiler would represent both enums below as a single byte.
On Thu, Mar 17, 2011 at 3:40 AM, AdrianPilko <[email protected]>wrote: > Are google protocol enumerated types (when built for C++) held in > memory from least significant bit zero. In other words does the > following enum fit in the least significant 2 bits of say an int: > > enum my2BitEnum { > a = 0; > b = 1; > c = 2; > d = 3; > } > > ...and does my8BitEnumQuestion only fit in a byte sized type (eg > char), or is it packed somehow to fit in the same memory space as > my2BitEnum: > > enum my8BitEnumQuestion { > a = 252; > b = 253; > c = 254; > d = 255; > } > > Thankyou > Adrian > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
