🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5387

Re: struct declarations in dpANS C

#5387
From: Karl Heuer
Date: Fri, 21 Oct 1988 19:34
22 lines
1507 bytes
In article <6157@june.cs.washington.edu> uw-june!pardo (David Keppel) writes:
>I have code of the form:
>    typedef void (*rtl_fp)( struct save_t *, int n,  rtl_t *curr );

Identifiers declared within a prototype have very short scope; thus for
example `n' has a scope that extends only to the end of the prototype.
Similarly (and more subtly), `struct save_t' has this same short scope if it
hasn't been previously declared.  When you later declare `struct save_t' it
has a nonintersecting scope, and therefore is considered a different type.

>[the error occurs] unless I precede the function declaration with
>    struct save_t;

That's the correct way to do it; if the struct tag is already declared when
the prototype is encountered, the one in the prototype becomes a reference to
it instead of a new type.

>In which case the compiler notes that there is an "empty declaration".

That is incorrect.  The struct tag is being declared.

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID: <9860@haddock.ima.isc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!bloom-beacon!spdcc!ima!haddock!karl
References: <6157@june.cs.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!bloom-beacon!spdcc!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.std.c
Subject: Re: struct declarations in dpANS C
Message-ID: <9860@haddock.ima.isc.com>
Date: 21 Oct 88 19:34:02 GMT
References: <6157@june.cs.washington.edu>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 21