alan@drivax.UUCP (Alan Fargusson) (04/23/85)
I noticed that the standard has defined structures and unions in such a way as to break most of my code. I don't like this very much. I only got a copy of the standard a couple of weeks ago, and have been playing with the grammer that someone posted to the net. 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; Has this been hashed over before? If it was I missed it. -- Alan Fargusson. { ihnp4, sftig, amdahl, ucscc, ucbvax!unisoft }!drivax!alan
alan@drivax.UUCP (Alan Fargusson) (04/25/85)
I blew it. The grammar that was posted to the net has a bug which I fixed as shown below. When I read the grammar in the standard I missed the fact that the tag is optional. Everything is okay. Before fix: struct_or_union_specifier : struct_or_union identifier '{' struct_declaration_list '}' | struct_or_union identifier ; After fix: struct_or_union_specifier : struct_or_union identifier '{' struct_declaration_list '}' | struct_or_union '{' struct_declaration_list '}' | struct_or_union identifier ; -- Alan Fargusson. { ihnp4, sftig, amdahl, ucscc, ucbvax!unisoft }!drivax!alan
john@x.UUCP (John Woods) (04/25/85)
> 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@MIT-XX.ARPA You can't spell "vile" without "vi".