Pointer types
The compiler has two basic types of pointers: function pointers and data pointers. Pointer types have the same alignment as the corresponding integer type.
Function pointers
For the RV32 architecture, function pointers are always 32 bits. For the RV64 architecture, function pointers are always 64 bits.
Data pointers
There is one data pointer available for the RV32 architecture and one data pointer for the RV64 architecture. The RV32 data pointer is 32 bits and its range is 0x0–0xFFFF'FFFF.The RV64 data pointer is 64 bits and its range is 0x0–0xFFFF'FFFF'FFFF'FFFF.
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 unsigned integer type to a pointer of a larger type is performed by zero extension
Casting a value of a signed integer type to a pointer of a larger type is performed by sign 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 RISC-V, the type used for size_t is unsigned int.
ptrdiff_t
ptrdiff_t is the signed integer type of the result of subtracting two pointers. In the IAR C/C++ Compiler for RISC-V, 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 RISC-V, the type used for intptr_t is signed long int.
uintptr_t
uintptr_t is equivalent to intptr_t, with the exception that it is unsigned.