GCC 4.5.0 Reports invalid warning
Dave Korn
dave.korn.cygwin@gmail.com
Fri Jul 16 00:30:00 GMT 2010
On 16/07/2010 01:21, J Decker wrote:
> Now it's happy, why can't it just define 'struct a' as an appropriate
> name as it used to, the strucutre still isn't defined.
That's just the way that C works, I'm afraid.
> (okay every other compiler I mention is MSVC, OpenWatcom, lcc, and gcc
> before now)
Nah, gcc-4.3.4 also doesn't like it:
> $ gcc -c pa.c -Wall -W
> pa.c:3: warning: 'struct a' declared inside parameter list
> pa.c:3: warning: its scope is only this definition or declaration, which is prob
> ably not what you want
> pa.c:8: error: conflicting types for 'f'
> pa.c:3: error: previous declaration of 'f' was here
> pa.c:8: warning: unused parameter 'a'
Nor does gcc-3.4.4:
> $ gcc-3 -c pa.c -Wall -W
> pa.c:3: warning: "struct a" declared inside parameter list
> pa.c:3: warning: its scope is only this definition or declaration, which is prob
> ably not what you want
> pa.c:8: warning: unused parameter 'a'
Even MSVC more-or-less spots it, if you turn up the default warning level:
> $ cl /c /W4 pa.c
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
> Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
>
> pa.c
> pa.c(3) : warning C4115: 'a' : named type definition in parentheses
> pa.c(8) : warning C4100: 'a' : unreferenced formal parameter
cheers,
DaveK
More information about the Gcc
mailing list