From: Ilguiz L. <ila...@in...> - 2004-09-08 03:21:44
|
On Tue, Sep 07, 2004 at 10:17:24PM -0400, Steve Kann wrote: > only issue left is that we use a zero-length array as the last member > of a structure; in gcc, this refers to the memory _after_ the end of > the structure, and was a neat hack that Mark did in libiax2. > > Unfortunately, nobody has come up with a similar construction that _is_ > portable to compilers which don't support this (simple) extension. Can these macros be used instead? It seems they still need the name of the last structure element. I can't recall why just sizeof(type) wasn't enough. #define STRUCT_OFFSET(type, member) ((uint8_t *)&(((type *)NULL)->member) - \ (uint8_t *)((type *)NULL)) #define STRUCT_END(type, member) (STRUCT_OFFSET(type, member) + \ sizeof(((type *)NULL)->member)) Thanks, -- Ilguiz Latypov home +1 (519) 569-8746 cell +1 (519) 998-2865 66 Wildlark Crescent Kitchener, Ontario N2N 3E9 |