This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Darwin warnings patrol


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]