Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!sdcsvax!ucbvax!ulysses!hector!jss From: jss@hector..UUCP (Jerry Schwarz) Newsgroups: comp.lang.c++ Subject: Re: bug with unions? Message-ID: <2772@ulysses.homer.nj.att.com> Date: Wed, 5-Aug-87 17:54:36 EDT Article-I.D.: ulysses.2772 Posted: Wed Aug 5 17:54:36 1987 Date-Received: Sat, 8-Aug-87 06:14:58 EDT References: <1910@Shasta.STANFORD.EDU> Sender: daemon@ulysses.homer.nj.att.com Reply-To: jss@hector (Jerry Schwarz) Organization: AT&T Bell Labs, Murray Hill Lines: 32 In article <1910@Shasta.STANFORD.EDU> satz@Shasta.UUCP (Greg Satz) writes: > >While trying to convert some code to use cfront I came across the >following anomoly. ... >union ttype { > struct na { > unsigned short hint; > unsigned short pint; > } na; ... >}; One of the subtle differences between C and C++ is that tags in C live in a different name space from ordinary (variable and function) identifiers whereas in C++ they live in the same name space. Thus the meaning of struct s { ... } s ; in C++ is not really defined by the C++ book. Changing the tag to be different from the member name also cures the problem. This is known as the "stat stat" problem around here because "stat" is the one identifier defined in the UNIX C header files as both a structure tag and an ordinary (in this case function) identifier. Jerry Schwarz Bell Labs Murray Hill