Need help with union trick: summary of replies

Eychaner, Glenn C. gceych at juliet.caltech.edu
Sun Jan 13 17:11:03 AEST 1991


In article <14836 at smoke.brl.mil>, gwyn at smoke.brl.mil (Doug Gwyn) writes...
>In article <1991Jan12.190021.16071 at nntp-server.caltech.edu> gceych at juliet.caltech.edu writes:
>- struct {
>-     variant_union {
>- 	unsigned char ch;
>- 	variant_struct {
>- 	    unsigned one : 1;
>- 	    unsigned two : 1;
>- 	    ...
>- 	    unsigned eig : 1;
>- 	} superfluous;
>-     } superfluous2;
>-     int i, j, k, x, y, z;
>- } mystructure;
> 
>Oh, gross.  If you use this highly nonstandard VMS C extension then
>you'll have to overhaul your code when you port it to a different
>environment.  It is much better to simply not use such unnecessary
>vendor-specific extensions in the first place.

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.  In fact, it was written
for a VAX station bought to eventually replace an 11/44.  At that rate of
replacement, the language will be obsolete before the code is. (The programs on
the 11/44 were written in an early Fortran.  Gross.  Which is just what they'll
think of VaxC by the time the programming needs to be ported.)

Besides, I happen to LIKE this particular construct for nested structures and
unions (as an option).  I hate remembering the names of all the intermediates.
Especially when the variables are all going to have different names anyway.

Direct flames to bit.bucket, please.

Glenn C. Eychaner | "We demand rigidly defined areas of doubt and uncertainty."
40386 N. Shore Ln `-----.                                             -D. Adams
Big Bear City, CA 92314 `-----------------------. !**** G O  N I N E R S ****!
Eychaner%SunCub.Caltech.edu at Xhmeia.Caltech.edu -|- Big Bear Solar Observatory



More information about the Comp.lang.c mailing list