Bo R
Bo R

Reputation: 2371

Why are uintptr_t and intptr_t optional types in the C (and C++) standard?

With C99 (and later standards) standard requires certain types to be available in the header <stdint.h>. For exact-width, e.g., int8_t, int16_t, etc..., they are optional and motivated in the standard why that is.

But for the uintptr_t and intptr_t type, they are also optional but I don't see a reason for them being optional instead of required.

Upvotes: 16

Views: 2099

Answers (1)

user7860670
user7860670

Reputation: 37549

On some platforms pointer types have much larger size than any integral type. I believe an example of such as platform would be IBM AS/400 with virtual instruction set defining all pointers as 128-bit. A more recent example of such platform would be Elbrus. It uses 128-bit pointers which are HW descriptors rather than normal addresses.

Upvotes: 16

Related Questions