ANSII C structures and unions

John Woods john at x.UUCP
Fri Apr 26 03:30:58 AEST 1985


> I noticed that the standard has defined structures and unions
> in such a way as to break most of my code...
> It didn't take me long to find anything that includes
> stdio.h fails because of the structure problem.
> The way I read the standard a structure must be declared as a template
> with a tag before being used to declare a variable. For example:
> 	struct pig { int a; int b; };
> 	struct pig hog;
> Not like this:
> 	struct { int a; int b; } hog;

Looking over my draft copy of the C Information Bulletin, it looks like
they still permit the old form.  Quoting,

C.5.2.1 Structure and union specifiers

Syntax
	struct-or-union-specifier:
		struct-or-union identifier-sub-opt { struct-declaration-list }

I.e., the identifier is optional.

They go into detail about the semantics of your first version, but not about
the second version.  I guess they figured that those who use that style
already understand it :-).

My copy of proto-C standard is a bad photocopy of a pencil-marked version of
the November 12, 1984 draft which was handed out at the February IEEE UNIX
Standards Committee (P1003) meeting.  Supposedly the pencil marks represented
the delta to the next draft.  What actually came out, I do not know.
-- 
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA

You can't spell "vile" without "vi".



More information about the Comp.lang.c mailing list