Next: , Previous: Pragma Complex_Representation, Up: Implementation Defined Pragmas


2.33 Pragma Component_Alignment

Syntax:

    pragma Component_Alignment (
         [Form =>] ALIGNMENT_CHOICE
      [, [Name =>] type_LOCAL_NAME]);
    
    ALIGNMENT_CHOICE ::=
      Component_Size
    | Component_Size_4
    | Storage_Unit
    | Default

Specifies the alignment of components in array or record types. The meaning of the Form argument is as follows:

`Component_Size'
Aligns scalar components and subcomponents of the array or record type on boundaries appropriate to their inherent size (naturally aligned). For example, 1-byte components are aligned on byte boundaries, 2-byte integer components are aligned on 2-byte boundaries, 4-byte integer components are aligned on 4-byte boundaries and so on. These alignment rules correspond to the normal rules for C compilers on all machines except the VAX.


`Component_Size_4'
Naturally aligns components with a size of four or fewer bytes. Components that are larger than 4 bytes are placed on the next 4-byte boundary.


`Storage_Unit'
Specifies that array or record components are byte aligned, i.e., aligned on boundaries determined by the value of the constant System.Storage_Unit.


`Default'
Specifies that array or record components are aligned on default boundaries, appropriate to the underlying hardware or operating system or both. The Default choice is the same as Component_Size (natural alignment).

If the Name parameter is present, type_LOCAL_NAME must refer to a local record or array type, and the specified alignment choice applies to the specified type. The use of Component_Alignment together with a pragma Pack causes the Component_Alignment pragma to be ignored. The use of Component_Alignment together with a record representation clause is only effective for fields not specified by the representation clause.

If the Name parameter is absent, the pragma can be used as either a configuration pragma, in which case it applies to one or more units in accordance with the normal rules for configuration pragmas, or it can be used within a declarative part, in which case it applies to types that are declared within this declarative part, or within any nested scope within this declarative part. In either case it specifies the alignment to be applied to any record or array type which has otherwise standard representation.

If the alignment for a record or array type is not specified (using pragma Pack, pragma Component_Alignment, or a record rep clause), the GNAT uses the default alignment as described previously.