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:

ModeWidthCompiler Type
QI8 bitsint8_t
HI16 bitsint16_t
SI32 bitsint32_t
DI64 bitsint64_t
SF32 bitsfloat
DF64 bitslong 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.