🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2830

Re: Pointers to Incomplete Types in Prototypes

#2830
From: Stephen Clamage
Date: Thu, 02 May 1991 15:24
28 lines
1540 bytes
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
Technical Details
Message-ID: <700@taumet.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!taumet!steve
References: <w!2g7+c@rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <w!2g7+c@rpi.edu>
Organization: Taumetric Corporation, San Diego
Lines: 28