Hacker News new | ask | show | jobs
by mkovach 1026 days ago

  "a typedef name was a complete surprise to me at this point in your program" 
Ah, the joys of fun compiler messages. I miss those days. I remember getting one from a vendor compiler that was:

  "No! But they'll only let me warn you. Danger Will Robinson! Danger!"
and:

  "Really! If you are fussing around with void *, just go home or at least back to your editor!"
I think the IT manager kept that as a vendor just because of the message (the SDK was meh, but also fun!).
1 comments

Not much of a C programmer, what's the context around void* being a big deal?
Void pointers refer to anything and nothing. They are everything and all encompassing. What is pointed to by the void pointer could be what you want or it could be another universe.

Dereferencing a void pointer has no meaning. The compiler can do anything it wants because it doesn't know how to interpret the memory. It could give you the correct thing, it could warp a civilization in from a distant planet, or it could open a world-ending black hole. All are equally probable.

You're correct, although I'm fairly sure dereferencing a `void*` is a compile error on all but the most ancient and non-conforming compilers. I'm not even sure what it _could_ compile to, given that `void` has no size.
void * was introduced after char * had been the pre-standard way of addressing any memory. Compilers of the era would let you use void * like char *, because it made it easier to change char * into void *.
Yes most modern C compilers will stop you from dereferencing a void pointer. Still, I couldn't help but bring up what can happen. Since I didn't witness it I can only assume 3 mile island was someone dereferencing a void pointer and it was easier to explain with a nuclear meltdown.
It really should be specified to specifically summon nasal demons, IMO.
Has any civilization been warped in already?
Not to my knowledge, but there seems to have been a slow warping out of civilization in recent years.