Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site psuvax1.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittvax!dcdwest!sdcsvax!akgua!psuvax1!dae
From: dae@psuvax1.UUCP (Daemon)
Newsgroups: net.lang.c
Subject: null union name allowed?
Message-ID: <1601@psuvax1.UUCP>
Date: Fri, 4-Jan-85 22:30:11 EST
Article-I.D.: psuvax1.1601
Posted: Fri Jan  4 22:30:11 1985
Date-Received: Mon, 7-Jan-85 02:13:29 EST
Distribution: net
Organization: The Furnace
Lines: 62


Consider the following fragment:
struct foo
	{
	int bar;
	union
		{
		char grill;
		long diner;
		};
	} fubar;
fubar.grill = 'e';

(1) is the null union name allowed ( K&R, ANSI ) ?
(2) do compilers In The Real World allow it ( Mark Williams,
DeSmet, Lattice, etc) ?

4.2 cc allows the structure definition, but bombs on the
fubar.grill.... line--mumbles something about illegal member usage.

I personally would like to see this added (if it's an addition) for the
following reasons:

(1) It seems that it's already (in some places) almost there,
(2) You get the space-saving you want without adding a useless
	intermediate member.

Side issue:
4.2bsd has a

union wait
	{
	stuff;
	stuff;
	};
Is this formally allowed?  Is it allowed in practice?
Personally, I feel this is a bit bogus, but it seems
to be a try at getting around a

struct wait
	{
	union foo
		{
		stuff;
		stuff;
		};
	};
Perhaps unnamed unions are the solution?  By the way, I seem
to remember some c compiler that had a (one) struct 0, and if
you said "struct x;" you got whatever struct 0 was...does this
ring a bell with anybody?

Replies to ...gondor!dae; The usual mumbles about mail and posting
summaries apply.
-- 

 
 \ / \/
  \  / From the furnace of Daemon ( ...{psuvax1,gondor,shire}!dae )
   \/  (814) 237-1901 "I will have no covenants but proximities" [Emerson]

When the going gets tough, the weird turn pro.