2 ms·
The equivalent to a void pointer in Go is interface{}. But very little of the C standard library uses void pointers--basically only those interfaces dealing wit
by wahern 6y ago
The equivalent to a void pointer in Go is interface{}. But very little of the C standard library uses void pointers--basically only those interfaces dealing with untyped blocks of memory, such as malloc and free. IME, you see interface{} far more often in Go code than you see void pointers in C code. And C actually has bone fide generics capabilities with _Generic, it's just very simple and manual.
- wing-_-nuts 6y agogo's empty interfaces reminded me too much of the bad old days when everyone passed around Objects to java methods. I hated it.
- Cyph0n 6y agovoid * is very useful as an opaque pointer type. For example, it's used all over the place in collection implementations and user-defined arguments (e.g., callbacks, pthread_create). It might not be used much in the stdlib (which is relatively small!), but libraries and applications rely on void * heavily in my experience.