Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.std.c Subject: Re: struct* mention before declaration/definition Message-ID: <20802@crdgw1.crd.ge.com> Date: 21 Jun 91 18:53:04 GMT References: <142762@unix.cis.pitt.edu> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Lines: 43 In article <142762@unix.cis.pitt.edu>, msw@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@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@crd.ge.com