From: Jason M. <ko...@gm...> - 2008-08-24 18:31:05
|
Stefanos A. wrote: > On Sun, Aug 24, 2008 at 6:31 AM, Branan Riley <br...@gm...> wrote: > >> Could be a different version of MSVC giving different >> warnings. >> > > Actually no, just stricter warnings (warning level 4, where the default > is 3). GCC doesn't produce any warnings even with -Wall. > > However, please note that the anonymous union is *not* valid C89 (fails > to compile with "gcc -ansi"). I'm not saying this is a problem (//-style > comments aren't valid C89 either), just something to keep in mind and > document. > > // Not valid C89 > union > { > float data[2]; > struct { float x, y; }; > }; > > /* Valid C89 */ > union foo_union > { > float data[2]; > struct bar_struct { float x, y; } bar; > } foo; > > Anyone knows if these have been standardized in C99? > Hmm, I did a test with VC7.1, and he's right: on warning level 4, it does produce a warning. Even when compiled as C++, it produces a warning. So this kind of anonymous structure is widely supported but invalid C89 behavior. I suppose you could pragma around it. |