On Mon, 23 Nov 2015 06:45:54 -0500 Hendrik Boom <hend...@topoi.pooq.com> wrote:
> There is a well-known hack in C wheereby you rely on C allocating > fields of structures independently of later fields. > > Thus with > struct foo{char c, int d, float e,} > and > struct bar{char c, int d,} > > (forgive me if I need semicolons here; I've used too many languages > in the alst year to remember the surface syntax) > > you can rely on c and d having the same offsets in both structures, > and so you can happily cast between pointers to foo and bar as long > as you don't mess with e. > > And, of course, you can have a pointer to a table of methods as the > first entry in all of these structures. Aren't C unions the "official" way to deal with these situations? SteveT Steve Litt November 2015 featured book: Troubleshooting Techniques of the Successful Technologist http://www.troubleshooters.com/techniques _______________________________________________ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng