9.10.8 mode
(mode)
This attribute specifies the data type for the declaration as whichever
type corresponds to the mode mode. This in effect lets
you request an integer or floating point type according to its width. Valid values for
mode are as follows:
| Mode | Width | Compiler Type |
|---|---|---|
| QI | 8 bits | int8_t |
| HI | 16 bits | int16_t |
| SI | 32 bits | int32_t |
| DI | 64 bits | int64_t |
| SF | 32 bits | float |
| DF | 64 bits | long double |
This attribute is useful for writing code that is portable across all supported compiler targets. For example, the following function adds two 32-bit signed integers and returns a 32-bit signed integer result:
typedef int32_t __attribute__((__mode__(SI))) int32;
int32 add32(int32 a, int32 b)
{
return(a+b);
}You may also specify a mode of byte or
__byte__ to indicate the mode corresponding to a one-byte integer,
word or __word__ for the mode of a one-word
integer, and pointer or __pointer__ for the mode used
to represent pointers.
