Re: pragma Convention ignored (sometimes)



Anonymous Coward wrote:

  type Some_Enum_Type is (one, two, three);

  pragma Convention (Convention => C, Entity => Some_Enum_Type);

should create a 32 bit enum, but in fact doing a 'size reveals that
it's 2 bits!

By default, 'Size on a subtype gives the minimum # of bits to represent the values of the type. In this case, that would be 2. 'Size of an object is something else, and in this case is probably more like what you expect. Without the pragma Convention, I'd expect it to be 8 on x86 targets.


As an example, with GNAT, Integer'Size is 32 and Natural'Size is 31. An object of subtype Natural, however, is usually 32 bits.

If you explicitly define the size of a subtype (for X'Size use 23;), then 'Size on the subtype should give the defined value.

--
Jeff Carter
"Now go away or I shall taunt you a second time."
Monty Python & the Holy Grail
07
.



Relevant Pages