Path: utzoo!attcan!uunet!mcvax!ukc!warwick!geoff From: geoff@cs.warwick.ac.uk (Geoff Rimmer) Newsgroups: comp.lang.c Subject: Re: Recursive #includes Message-ID: <1567@ubu.warwick.UUCP> Date: 11 Mar 89 17:11:29 GMT References: <570@marob.MASA.COM> <9727@smoke.BRL.MIL> <964@philmds.UUCP> <3804@xyzzy.UUCP> <7488@june.cs.washington.edu> <9804@smoke.BRL.MIL> Sender: news@warwick.UUCP Organization: Computer Science, Warwick University, UK Lines: 61 In-reply-to: gwyn@smoke.BRL.MIL's message of 6 Mar 89 16:28:10 GMT In article <9804@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <7488@june.cs.washington.edu> ka@june.cs.washington.edu (Kenneth Almquist) writes: > >I've been told that incomplete types cannot be used in function prototypes. > > I couldn't find such a prohibition in the pANS. > (But maybe it's there and I missed it.) gcc will not allow it: Script started on Sat Mar 11 17:04:06 1989 --geoff@emerald% cat str.c static void function (struct egg * a); struct egg { int number1; float number2; }; static void function (struct egg * a) { printf("In function with [%d,%f]\n",a->number1,a->number2); } extern void main (void) { struct egg aa; aa.number1=23; aa.number2=12.345; function(&aa); } --geoff@emerald% gcc -v gcc version 1.34 --geoff@emerald% gcc -ansi -pedantic str.c str.c:1: warning: `struct egg' declared inside parameter list str.c: In function function: str.c:6: conflicting types for `function' str.c:1: previous declaration of `function' --geoff@emerald% exit script done on Sat Mar 11 17:05:06 1989 The strange thing is that it doesn't barf on the struct void function (struct egg *a); line, even though the structure is as yet undefined. The problem is when it compares the types of the function's arguments, and sees that in the call to the function, the argument is type (struct egg *) and in the declaration it is unknown. Is this a problem with gcc, or does this happen with all ANSI compilers? Geoff ------------------------------------------------------------ Geoff Rimmer, Computer Science, Warwick University, England. geoff@uk.ac.warwick.emerald "Ahhh, bonjour, monsieur." "Sod off." - Blackadder 3. ------------------------------------------------------------