Skip to main content

IAR Embedded Workbench for RX 5.20

Pointer types

In this section:

The compiler has two basic types of pointers: function pointers and data pointers. Pointer types have the same alignment as the corresponding integer type.

Casting

Casts between pointers have these characteristics:

  • Casting a value of an integer type to a pointer of a smaller type is performed by truncation

  • Casting a value of an integer type to a pointer of a larger type is performed by zero extension

  • Casting a pointer type to a smaller integer type is performed by truncation

  • Casting a pointer type to a larger integer type is performed by zero extension

  • Casting a data pointer to a function pointer and vice versa is illegal

  • Casting a function pointer to an integer type gives an undefined result

size_t

size_t is the unsigned integer type of the result of the sizeof operator. In the IAR C/C++ Compiler for RX, the type used for size_t is unsigned long.

ptrdiff_t

ptrdiff_t is the signed integer type of the result of subtracting two pointers. In the IAR C/C++ Compiler for RX, the type used for ptrdiff_t is the signed integer variant of the size_t type.

intptr_t

intptr_t is a signed integer type large enough to contain a void*. In the IAR C/C++ Compiler for RX, the type used for intptr_t is signed long.

uintptr_t

uintptr_t is equivalent to intptr_t, with the exception that it is unsigned.