struct* mention before declaration/definition
Christopher R Volpe
volpe at camelback.crd.ge.com
Sat Jun 22 04:53:04 AEST 1991
In article <142762 at unix.cis.pitt.edu>, msw at unix.cis.pitt.edu (Matt S
Wartell) writes:
|> /* declaration of function */
|> void add_version(int a, struct B *b);
^^^^^^^^ Implicit declaration of incomplete
type whose scope is the
prototype itself.
You don't want this.
|>
|> /* definition of structure */
|> struct B {
|> ...
|> };
Declaration of new type not yet seen at this scope. This is fine.
|>
|> /* definition of function */
|> void add_version(int a, struct B *b)
^^^^^^^^
Reference to type already declared in outer
scope above. This type is a DIFFERENT TYPE
from the one that appears in the prototype
declaration.
|> {
|> ...
|> }
|>
|>When the compiler gets to the function definition, it complains of a type
|>mismatch in parameter b. It is our impression that the compiler should
|>produce an error at the function _declaration_ because the declaration
|>uses an undefined, undeclared type.
|>--
|>matt wartell, university of pittsburgh msw at unix.cis.pitt.edu
The compiler is correct. Move the declaration of struct B before the
prototype.
-Chris
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com
More information about the Comp.std.c
mailing list