Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.std.c Subject: Re: Pointers to Incomplete Types in Prototypes Message-ID: <700@taumet.com> Date: 2 May 91 15:24:07 GMT References: Organization: Taumetric Corporation, San Diego Lines: 28 xor@aix01.aix.rpi.edu (Joseph Schwartz) writes: >More specifically, if struct bar has not been defined, is an ANSI >compiler allowed to reject the following prototype: > > extern void foo(struct bar *); >Our HP "ANSI" C compiler is complaining >about the above prototype, and I want some ammunition before I report >it to HP as a problem. There was another answer posted to this question which was not complete. As shown, the prototype declares "struct bar" to be an incomplete type *local to the prototype*, and hence unavailable outside the prototype. It is then impossible to call this function, since no object of type "struct bar" (or pointer to one) could ever exist. (Any later "struct bar" is a new type in a different scope.) The compiler may have been complaining about this. If you precede the declaration with an incomplete decl for bar, the prototype now refers to that decl, and all is well. Example: struct bar; /* defined later */ extern void foo(struct bar*); /* refers to previous bar */ You didn't say whether there was a prior incomplete decl. -- Steve Clamage, TauMetric Corp, steve@taumet.com