Skip to main content

IAR Embedded Workbench for RL78 5.20

Basic data types—integer types

In this section:

The compiler supports both all Standard C basic data types and some additional types.

Integer types—an overview

This table gives the size and range of each integer data type:

Data type

Size

Range

Alignment

bool

8 bits

0 to 1

1

char

8 bits

0 to 255

1

signed char

8 bits

-128 to 127

1

unsigned char

8 bits

0 to 255

1

signed short

16 bits

-32768 to 32767

2

unsigned short

16 bits

0 to 65535

2

signed int

16 bits

-32768 to 32767

2

unsigned int

16 bits

0 to 65535

2

signed long

32 bits

-231 to 231-1

2

unsigned long

32 bits

0 to 232-1

2

signed long long

64 bits

-263 to 263-1

2

unsigned long long

64 bits

0 to 264-1

2

Table 76. Integer types 


Signed variables are represented using the two’s complement form.

Bool

The bool data type is supported by default in the C++ language. If you have enabled language extensions, the bool type can also be used in C source code if you include the file stdbool.h. This will also enable the boolean values false and true.

The enum type

The compiler will use the smallest type required to hold enum constants, preferring signed rather than unsigned.

When IAR language extensions are enabled, and in C++, the enum constants and types can also be of the type long, unsigned long, long long, or unsigned long long.

To make the compiler use a larger type than it would automatically use, define an enum constant with a large enough value. For example:

/* Disables usage of the char type for enum */
enum Cards{Spade1, Spade2,
           DontUseChar=257};

See also the C++ enum struct syntax.

The char type

The char type is by default unsigned in the compiler, but the ‑‑char_is_signed compiler option allows you to make it signed.

Note

The library is compiled with the char type as unsigned.

The wchar_t type

The wchar_t data type is 4 bytes and the encoding used for it is UTF-32.

The char16_t type

The char16_t data type is 2 bytes and the encoding used for it is UTF-16.

The char32_t type

The char32_t data type is 4 bytes and the encoding used for it is UTF-32.