3 ms·
There's some good stuff here. I'd like to offer a critique of the proposed solution to casting pointers to integer types, though. The post suggests using uintp
by mikeash 11y ago
There's some good stuff here.
I'd like to offer a critique of the proposed solution to casting pointers to integer types, though. The post suggests using uintptr_t or similar when manipulating pointer types, to avoid 64-bit troubles. For the particular case of adding a number of bytes to a pointer, I'd recommend using char* instead. That bypasses the whole question of "what integer type is big enough?" and helps avoid mistakes like accidentally dividing or multiplying the number, or passing it in to something that wants an integer.