I know that uintptr_t and intptr_t are some abstract integer types capable to hold any void pointer.
The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: intptr_t The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: uintptr_t These types are optional.
As I understand they hold some abstract integer values and its arithmetic makes a little or no sense in the C standard understanding.
example:
//assumptions:
//start & end are referencing the same array or next element past the end of the array and end - start >= 0
size_t objsize(const void *restrict start, const void *restrict end)
{
return (size_t)((uintptr_t)end - (uintptr_t)start);
}
Most known to me implementation it will return the difference in bytes, but I think is implementation defined (or even undefined).
Am I right or wrong? Does the arithmetic of those types give any meaningful information?