When is casting void pointer needed in C?

No need to cast from or to a pointer to void in C:

6.3.2.3 Pointers

1
A pointer to void may be converted to or from a pointer to any incomplete or object
type. A pointer to any incomplete or object type may be converted to a pointer to void
and back again; the result shall compare equal to the original pointer.


The only exceptions from this are

  • when printing a pointer using the "%p" conversion specifier as it’s only defined for void *.
  • when copying a pointer’s value from an intptr_t or uintptr_t back to a void *.

Leave a Comment

techhipbettruvabetnorabahisbahis forumuedusedusedueduseduseduseduedusedusedu