Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site cwruecmp.UUCP
Path: utzoo!linus!decvax!cwruecmp!decot
From: decot@cwruecmp.UUCP (Dave Decot)
Newsgroups: net.lang.c
Subject: Re: 'struct' - declarations & parameters
Message-ID: <1037@cwruecmp.UUCP>
Date: Tue, 21-Feb-84 21:33:57 EST
Article-I.D.: cwruecmp.1037
Posted: Tue Feb 21 21:33:57 1984
Date-Received: Wed, 22-Feb-84 04:42:04 EST
References: <4033@edai.UUCP>, <5317@umcp-cs.UUCP>
Organization: CWRU Computer Engr. Cleveland, Ohio
Lines: 42

Chris Torek says:

    ...writing

	struct { int i, j, k; } foo = { 1, 2, 3 };

	main () { printf ("%d %d %d\n", foo); }

    is just plain illegal.
    
This code is NOT illegal, nor is it illegal to pass unions.  It is only
non-portable (but lint(1) has no complaint, because the problem is in
printf).  In fact, it usually works (for example, on our VAX, 4.1bsd).  Some
recent changes to C allow you to pass structures and unions as parameters to
functions.  If your compiler has no `enum' types, then it is outdated, and
probably doesn't support struct/union parameter passing.

    As to whether the trailing semicolon is required in structure
    declarations:  all I can say is it doesn't hurt to use it.  (Though
    if you want type declarations to match function declarations, it
    should be optional.  I don't have to write "dummy () { ; }".)

It isn't, and should not be, optional.  The VAX compiler doesn't signal this
as a syntax error, but it should, since it is.  The fact that you need no
semicolon in a dummy function body is no demonstration of inconsistency,
it is a demonstration of consistency.  Statements in C are *terminated*
(not separated, as in Pascal) by a semicolon.  It is only natural that every
declaration (including field declarations) must also be terminated by a
semicolon.

The function body in

    dummy () { ; } 

is allowed and interpreted as a null statement, but in

    dummy () { }

there is no statement (since none are required), and thus no ; is needed.

Dave Decot		 "Non-Americans are people, too."
decvax!cwruecmp!decot    (Decot.Case@rand-relay)