home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!europa.eng.gtefsd.com!emory!swrinde!sdd.hp.com!usc!howland.reston.ans.net!bogus.sura.net!darwin.sura.net!ukma!cs.widener.edu!dsinc!ub!galileo.cc.rochester.edu!rochester!rit!cci632!dwr
- From: dwr@cci632.cci.com (Donald W. Rouse II)
- Newsgroups: comp.std.c++
- Subject: Re: structs that define nothing
- Message-ID: <1993Jan27.173319.15550@cci632.cci.com>
- Date: 27 Jan 93 17:33:19 GMT
- References: <1993Jan25.171222.1@fnalng.fnal.gov>
- Organization: [Computer Consoles, Inc., Rochester, NY
- Lines: 34
-
- In article <1993Jan25.171222.1@fnalng.fnal.gov> b91926@fnalng.fnal.gov writes:
- >Does the c++ standard have anything to say about the legality of a
- >construct like the following:
- >
- >...
- >struct
- >{
- > int a;
- > int b;
- >};
- >
- >...
- >
- >Such an example appeared in a recent issue of "C++ Report". The
- >problem with this code is that it defines absolutely nothing.
-
- This example reminds me of a possible extension to C++ (and C)
- that could occasionally be useful: anonymous structures,
- which are analogous to anonymous unions.
-
- Example:
- typedef union
- {
- unsigned long lw;
- struct { unsigned short sw0, sw1; };
- struct { unsigned char b0, b1, b2, b3; };
- } machword;
- machword r1, r2;
-
- Now you can access r1.b2, instead of having to do
- something like r1.b.b2, etc.
-
- Note that the only place this would be useful
- is inside a union.
-