Overview
Pointers have the same size as the machine’s word size since it should be able to refer to any virtual address. All pointers are either valid, null, or indeterminate.
C allows arithmetic on pointers, where the computed value is scaled according to the size of the data type referenced by the pointer.
NULL
The NULL
macro refers to a null pointer constant, an ICE with value 0
or such an expression cast to type void*
. The following table lists some valid values NULL
can take on:
Expansion | Type |
---|---|
0U | unsigned |
0 | signed |
\0 | signed |
Enum constant of value 0 | signed |
0UL | unsigned long |
0L | signed long |
0ULL | unsigned long long |
0LL | signed long long |
(void*)0 | void* |
Aliasing
Accessing the same object through different pointers is called aliasing. With the exclusion of character types, only pointers of the same base type may alias.
Bibliography
- Jens Gustedt, Modern C (Shelter Island, NY: Manning Publications Co, 2020).