Need help with union trick: summary of replies
Karl Heuer
karl at ima.isc.com
Tue Jan 15 07:42:22 AEST 1991
[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 at nntp-server.caltech.edu> gceych at 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 at ima.isc.com or uunet!ima!karl), The Walking Lint
More information about the Comp.lang.c
mailing list