Path: 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 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