Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!zaphod!pacific.mps.ohio-state.edu!linac!att!att!ima!dirtydog!karl From: karl@ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Need help with union trick: summary of replies Message-ID: <1991Jan14.204222.7867@dirtydog.ima.isc.com> Date: 14 Jan 91 20:42:22 GMT References: <28949@mimsy.umd.edu> <2885@cirrusl.UUCP> <1991Jan12.190021.16071@nntp-server.caltech.edu> <14836@smoke.brl.mil> <1991Jan13.072418.1745@nntp-server.caltech.edu> Sender: news@dirtydog.ima.isc.com (NEWS ADMIN) Organization: Interactive Systems Lines: 24 [DEC's compiler apparently allows you to write things like struct { variant_union { int x; float y; } superfluous; } str; and write str.x to reference the components. Doug Gwyn notes that this is gross, nonstandard, etc.] In article <1991Jan13.072418.1745@nntp-server.caltech.edu> gceych@juliet.caltech.edu writes: >The piece of code of which this is a small part contains so many system >calls, kludges, etc. that portability is not a major concern. I'll accept your judgement on that point. >Besides, I happen to LIKE this particular construct for nested structures and >unions (as an option). I like the functionality, but not the syntax. The "anonymous union" struct { union { int x; float y; }; } str; is much better. This, too, is not part of the current ANSI C Standard, but it stands a much better chance of being accepted into C-2001. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint