This section explains the internal representation and value area of each type for the data handled by the CC-RH.
The leftmost bit in an area is a sign bit with a signed type (type declared without "unsigned"). The value of a signed type is expressed as 2' s complement.
Internal Representation of floating-point data type conforms to IEEE754Note. The leftmost bit in an area of a sign bit. If the value of this sign bit is 0, the data is a positive value; if it is 1, the data is a negative value.
IEEE: Institute of Electrical and Electronics Engineers |
When -Xdbl_size=4 is specified, the double and long double types have the same internal representation and the same value area as those of the float type.
The internal representation of a pointer type is the same as that of an unsigned int type.
The internal representation of an enumerate type is the same as that of a signed int type. The leftmost bit in an area of a sign bit.
When the -Xenum_type=auto option is specified, see "(31) Enumerate type specifier".
The internal representation of an array type arranges the elements of an array in the form that satisfies the alignment condition (alignment) of the elements
The internal representation of the array shown above is as follows.
The internal representation of a structure type arranges the elements of a structure in a form that satisfies the alignment condition of the elements.
The internal representation of the structure shown above is as follows.
For the internal representation when the structure type packing function is used, see "4.2.4.8 Structure type packing".
A union is considered as a structure whose members all start with offset 0 and that has sufficient size to accommodate any of its members. The internal representation of a union type is like each element of the union is placed separately at the same address.
The internal representation of the union shown in the above example is as follows.
The most significant bit of a bit field declared as a signed type, or without an explicit sign declaration, will be the sign bit. The first bit field to be declared will be allocated starting from the least significant bit in the area with the sign of the type when the bit field was declared. If the alignment condition of the type specified in the declaration of a bit field is exceeded as a result of allocating an area that immediately follows the area of the preceding bit field to the bit field, the area is allocated starting from a boundary that satisfies the alignment condition.
You can allocate the members of a bit field starting from the most significant bit using the -Xbit_order=left option or by specifying #pragma bit_order left. See "4.2.4.9 Bit field assignment" for details.
The internal representation for the bit field in the above example is as follows.
The internal representation for the bit field in the above example is as follows.
While the ANSI C standard only allows int and unsigned int types to be specified for a bit field, the CC-RH allows char, short, long, long long and their unsigned types.
For the internal representation of bit field when the structure type packing function is used, see "4.2.4.8 Structure type packing".
Alignment condition for basic type is as follows.
If the -Xinline_strcpy option of the CC-RH is specified, however, all the arrey types are 4-byte boundaries.
Other basic types (including pointer) |
|
The alignment conditions for a union type are the same as those of the structure's member whose type has the largest alignment condition.
Here are examples of the respective cases:
union tug1 { unsigned short i; /*2 bytes member*/ unsigned char c; /*1 bytes member*/ }; /*The union is aligned with 2-byte.*/ |
union tug2 { unsigned int i; /*4 bytes member*/ unsigned char c; /*1 byte member*/ }; /*The union is aligned with 4-byte.*/ |
The alignment conditions for a structure type are the same as those of the structure's member whose type has the largest alignment condition.
Here are examples of the respective cases:
struct ST { char c; /*1 byte member*/ short s; /*2 bytes member*/ }; /*Structure is aligned with 2-byte.*/ |
struct ST { char c; /*1 byte member*/ short s; /*2 bytes member*/ short s2; /*2 bytes member*/ }; /*Structure is aligned with 2-byte.*/ |
struct ST { char c; /*1 byte member*/ short s; /*2 bytes member*/ int i; /*4 bytes member*/ }; /*Structure is aligned with 4-byte.*/ |
struct ST { char c; /*1 byte member*/ short s; /*2 bytes member*/ int i; /*4 bytes member*/ long long ll; /*4 bytes member*/ }; /*Structure is aligned with 4-byte.*/ |
The alignment condition for a function argument is a 4-byte boundary.
The alignment condition when an executable object module file is created by linking object files is 2-byte boundary.