 | CARM User's Guide Discontinued |  |
|
|
| PointersThe 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 From | Convert To | Description |
|---|
signed long long unsigned long long | pointer | The 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 | pointer | The four bytes of the int or long type are used as the pointer value. | unsigned char unsigned short | pointer | The byte or bytes of the char or short are zero-extended to fill the four bytes of the pointer. | signed char signed short | pointer | The byte or bytes of the char or short are sign-extended to fill the four bytes of the pointer. | | pointer | signed long long unsigned long long | The four bytes of the pointer are zero-extended to fill the eight bytes of the long long. | | pointer | signed int unsigned int signed long unsigned long | The four bytes of the pointer are used as the int or long value. | | pointer | signed short unsigned short | The high-order two bytes of the pointer are discarded. The low-order two bytes are used as the short value. | | pointer | signed 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.
|
|