Comment by teo_zero
5 months ago
Yes, some restrictions seem arbitrary. Just like why these two types are not compatible:
struct a {int data;};
struct b {int data;};
I know, I know, changing it would break existing code, etc.
5 months ago
Yes, some restrictions seem arbitrary. Just like why these two types are not compatible:
struct a {int data;};
struct b {int data;};
I know, I know, changing it would break existing code, etc.
You jest, but a central feature of C is that void* is a universal pointer, and can be used as the basis of polymorphism and context passing. That's why you can do things like:
It would be nice to write:
But instead we have to write this to avoid being declared "undefined behaviour":
So what is the upside of having this rule, given the same thing is going to happen anyway, just more verbose?