3 ms·
Or you can call a function without a prototype (no longer allowed in C99, thankfully), call a function whose prototype's type signature doesn't match the implem
by mikeash 12y ago
Or you can call a function without a prototype (no longer allowed in C99, thankfully), call a function whose prototype's type signature doesn't match the implementation, access a global variable whose declaration doesn't match the definition, access a struct using a different declaration than the one used by whoever put the data there in the first place, or just do an accidental type pun through a void *, which requires no casting. It's not at all hard to do by accident. Much of this is why binary compatibility for libraries written in C is so hard to achieve over the long term.
I agree that type promotion isn't the same, but I didn't mention that anyway....
- AnimalMuppet 12y agoArgh. I forgot that C doesn't do name mangling. Most of those problems go away in C++, though (he said hopefully, but without complete confidence...)
- mikeash 12y agoThe problem of mismatched prototypes goes away (except for extern "C" functions, of course) but then you get fun stuff like fragile base classes. If you have a base class in a library and a subclass in an application that links against that library, you can never add a virtual function to the base class again without breaking backwards compatibility (and causing all sorts of accidental type-punning chaos when you try to call methods).