On Sun, Jul 1, 2012 at 6:45 PM, erik quanstrom wrote: > > Many compilers do just that, however, that said, unless the compiler is > > prepared for it, since it effectively yields a struct of zero size which > > normally is a no-go, it could produce bugs involving sizeof, > initializers, > > pointer addition et al, even some divisions by zero if the compiler is > > making certain assumptions already, unless it already can have zero > length > > objects of this nature for some other reasons. > > actually, kenc is pretty good about all these. if you have > > struct fu {void x;}; > > and take sizeof(struct fu), that will give a diagnostic error. > > the reason i avoided it was to not mess with the grammer, but if this is a > common thing, maybe it's no big deal. > > though as charles points out, it is a bit of a waste of time. > If my memory serves, there is some wiggle room in C89 about how the empty struct works, though generally it wouldn't fly, and C99 disallows it, while C++ allows it (but it's sizeof > 0). Plus it's a common extension made prevalent via gcc. -- Greg Comeau / 4.3.10.1 with C++0xisms now in beta! Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries... Have you tried it?