If I subtract two void pointers, I get the relative distance in bytes (at least on my test system I do) between the pointer locations. What type should I use to store the result in, such that it is compatible with 64-bit systems? Is size_t the correct type or perhaps long?
Background: we need to check whether a given void pointer is safe to be used as a double pointer. We used to cast the pointer to int and check that the lower three bits are zero, however our current coding standards do not allow casting pointers to integer types anymore. I am considering calculating the difference between the void pointer and the NULL pointer and checking whether that difference is dividable by 8. Assuming that the NULL pointer is always 8-byte aligned?