This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Darwin warnings patrol
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Neil Booth <neil at daikokuya dot co dot uk>
- Cc: Stan Shebs <shebs at apple dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 Jan 2003 16:58:36 -0800
- Subject: Re: Darwin warnings patrol
- References: <3E289C93.8000902@apple.com><20030118004145.GA10848@daikokuya.co.uk>
Neil Booth <neil@daikokuya.co.uk> writes:
> Stan Shebs wrote:-
>
>> + struct cpp_reader;
>> extern void darwin_pragma_ignore PARAMS ((struct cpp_reader *));
>> extern void darwin_pragma_options PARAMS ((struct cpp_reader *));
>> extern void darwin_pragma_unused PARAMS ((struct cpp_reader *));
>
> This shouldn't be necessary. The one in PARAMS is a declaration.
Actually it is. This trips over one of the weirdest rules in the C
standard: that implicitly declares 'struct cpp_reader' with scope only
of the prototype itself, which means that darwin_pragma_ignore (e.g.)
will *not* be type compatible with the 'real' struct cpp_reader, which
obviously makes it less than useful. Hence the on-by-default
three-line warning:
test.c:1: warning: `struct foo' declared inside parameter list
test.c:1: warning: its scope is only this definition or declaration,
which is probably not what you want.
However, I think it would be better to shove these forward
declarations into coretypes.h; that's what it's there for. We could
even move the typedefs there as well, allowing
extern void darwin_pragma_ignore PARAMS ((cpp_reader *));
zw