Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Is this a GCC bug ? Message-ID: <15822@haddock.ima.isc.com> Date: 1 Feb 90 16:12:37 GMT References: <7948@shlump.nac.dec.com> <355@charyb.COM> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 23 In article <355@charyb.COM> dan@charyb.UUCP (Dan Mick) writes: >In article <7948@shlump.nac.dec.com> nadkarni@ashok.dec.com writes: >|Is this a bug in the Gnu CC compiler or is it illegal C ? >| typedef void foo(struct urb *p); >| struct urb { int i; } ; >|bug.c:1: warning: `struct urb' declared inside parameter list >|bug.c:1: warning: such a name is accessible only within its parameter list, >|bug.c:1: warning: which is probably not what you want. The problem is that you have two declarations of `struct urb', and they have nonintersecting scopes--so they actually declare two different types. You should either put the typedef before the prototype, or else force a common scope by adding the empty declaration `struct urb;' at the top. >[partially correct analysis omitted] >The program still works, right? Since it can be derived that `all struct pointers smell the same', the program will probably work. But when you try to invoke foo() with an argument of type `struct_urb_2_pointer', the prototype requires the compiler to convert it to a `struct_urb_1_pointer', which may yield another warning. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint