Node: Component_Size Clauses, Next: , Previous: Value_Size and Object_Size Clauses, Up: Representation Clauses and Pragmas



Component_Size Clauses

Normally, the value specified in a component clause must be consistent with the subtype of the array component with regard to size and alignment. In other words, the value specified must be at least equal to the size of this subtype, and must be a multiple of the alignment value.

In addition, component size clauses are allowed which cause the array to be packed, by specifying a smaller value. The cases in which this is allowed are for component size values in the range 1-63. The value specified must not be smaller than the Size of the subtype. GNAT will accurately honor all packing requests in this range. For example, if we have:

     type r is array (1 .. 8) of Natural;
     for r'Size use 31;
     

then the resulting array has a length of 31 bytes (248 bits = 8 * 31). Of course access to the components of such an array is considerably less efficient than if the natural component size of 32 is used.