CARM User's Guide

Discontinued

Pointers

The CARM Compiler supports the declaration of variable pointers. Pointers may be used to perform all operations available in standard C. A pointer is a 32-bit unsigned integer value that represent a memory address in the 4 GByte address space of the ARM device. There is no difference between a data or a function pointer. Pointers may be freely cast to int and long types with no loss of address information.

You may cast an integer data type into a pointer and a pointer into an integer data type. Type cast operations between pointers and integer data types are performed as follows:

Convert FromConvert ToDescription
signed long long
unsigned long long
pointerThe high-order four bytes of the long long type are discarded. The low-order four bytes are used as the pointer value.
signed int
unsigned int
signed long
unsigned long
pointerThe four bytes of the int or long type are used as the pointer value.
unsigned char
unsigned short
pointerThe byte or bytes of the char or short are zero-extended to fill the four bytes of the pointer.
signed char
signed short
pointerThe byte or bytes of the char or short are sign-extended to fill the four bytes of the pointer.
pointersigned long long
unsigned long long
The four bytes of the pointer are zero-extended to fill the eight bytes of the long long.
pointersigned int
unsigned int
signed long
unsigned long
The four bytes of the pointer are used as the int or long value.
pointersigned short
unsigned short
The high-order two bytes of the pointer are discarded. The low-order two bytes are used as the short value.
pointersigned char
unsigned char
The high-order three bytes of the pointer are discarded. The low-order byte is used as the char value.

The CARM Compiler provides two standard types you may use with pointers.

  • size_t is defined as unsigned int and holds the maximum size of an object.
  • ptrdiff_t is defined as signed int and holds the difference between two pointers to elements of the same array.