The primary reason, you cannot do bitwise operation on a void *
, but you can do the same on a intptr_t
.
On many occassion, where you need to perform bitwise operation on an address, you can use intptr_t
.
However, for bitwise operations, best approach is to use the unsigned
counterpart, uintptr_t
.
As mentioned in the other answer by @chux, pointer comparison is another important aspect.
Also, FWIW, as per C11
standard, §7.20.1.4,
These types are optional.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…