Xref: utzoo comp.lang.c:20241 comp.std.c:1451 Path: utzoo!attcan!uunet!dino!uxc.cso.uiuc.edu!garcon!uicsrd.csrd.uiuc.edu!mcdaniel From: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Misdeclaring "main" Message-ID: <1612@garcon.cso.uiuc.edu> Date: 29 Jul 89 06:02:18 GMT References: <28398@beta.lanl.gov> <14020068@hpisod2.HP.COM> <2268@auspex.auspex.com> <13104@bloom-beacon.MIT.EDU> Sender: news@garcon.cso.uiuc.edu Reply-To: mcdaniel@uicsrd.csrd.uiuc.edu (Tim McDaniel) Followup-To: comp.std.c Organization: Center for Supercomputing R&D (Cedar), U. of Ill. Lines: 54 This is cross-posted to comp.lang.c (original article's newsgroup) and comp.std.c (I have standards questions). Followups have been redirected to comp.std.c. In article <13104@bloom-beacon.MIT.EDU> scs@adam.pika.mit.edu (Steve Summit) writes: >The production > > struct { struct-decl-list } id (arg-list) decl-list compound-statement > >yields a function that cannot be (correctly) called, since no >other object can be declared with a type-equivalent structure. I'm not so sure. Separate compilation is allowed in C, but struct tags (and their definitions) are not global in scope; for external linkage, only the types and order of the struct's members matter. I would think the following declarations are strictly conforming: in foo.c: extern struct { int f1; float f2; } func(); ... in bar.c: struct { int a6; float whacky; } func() ... However, K&R 2, 1st edition, p. 213 says A structure or union specifier with a list but no tag creates a unique type; it can referred to directly only in the declaration of which it is a part. >The production > > struct tag { struct-decl-list } id (arg-list) ... > >yields a function that can only be called by routines appearing >later in the same file. This statement is even more problematical. How does it differ from struct tag { struct-decl-list }; struct tag id (arg-list) ... ? If there is no difference, the "struct tag" declaration could just as easily be in an include file, and another file could include it and declare extern struct tag id (); Surely *this* behavior is blessed by the standard. -- "Let me control a planet's oxygen supply, and I don't care who makes the laws." - GREAT CTHUHLU'S STARRY WISDOM BAND (via Roger Leroux) __ \ Tim, the Bizarre and Oddly-Dressed Enchanter \ mcdaniel@uicsrd.csrd.uiuc.edu /\ mcdaniel%uicsrd@{uxc.cso.uiuc.edu,uiuc.csnet} _/ \_ {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel