I want to add a field to a structure in C. So for example I have the following structure.
struct A { some_type x; some_type y; }
I declare a
Yes, it would work. A a will be the first member in the struct
This is how some people simulated OO inheritance in C
You may use
&b->a
instead of the cast. And probably do an ASSERT like
ASSERT (&b->a == b)
to be warned when you accidentally destroyed this semantic