Standard for union initialization?
Dick Grune
dick at tjalk.UUCP
Mon Jan 21 20:14:05 AEST 1985
I saw a suggestion in net.lang.c a few months ago that I found very sensible,
readable and hygienic:
union {
int i;
float x;
char *str;
} ixstr = { , 3.14, };
if you want it to start off as a float, etc.
Note that:
1. it is (almost) isomorphous to a struct initialization,
2. it also works nicely for arrays of unions.
Dick Grune
Vrije Universiteit
de Boelelaan 1081
1081 HV Amsterdam
the Netherlands
... and my name isn't Richard.
More information about the Comp.lang.c
mailing list