Re: How To Disable A Specific Warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 2008-12-29 01:16, Bob Smith wrote:

> Jan Engelhardt wrote:
>> On Sunday 2008-12-28 19:35, Bob Smith wrote:
>>> ------------foo.c:-------------------
>>> typedef struct tagFOO
>>> {
>>>   int a;
>>> } FOO;
>>>
>>> void FCN (FOO* b)
>>> {
>>> }
>>> ------------foo.pro:-----------------
>> (should preferably be named foo.h)
>>> void FCN (struct tagFOO *b);
>>> ------------fop.c:-------------------
>>> #include "foo.pro"
>>> -------------------------------------
>>> In file included from fop.c:1:
>>> foo.pro:1: warning: "struct tagFOO" declared inside parameter list
>>> foo.pro:1: warning: its scope is only this definition or declaration, which
>>> is
>>> probably not what you want
>>>
>>> I'm trying to keep the dependency tree down to a minimum, so having to
>>> declare
>>> tagFOO within <fop.c> is counter to that goal.
>>
>> Well define it in foo.pro:
>> 	struct tagFOO;
>>
>> Keeping the dependency tree to a minimum is a good idea, but typedefs
>> will happily interfere with that; http://lkml.org/lkml/2006/11/21/34,
>> I suggest to just remove them entirely.
>
> You raise an interesting point, but I'm afraid I oversimplified the statement
> of the problem so as to focus on the question of how to disable the warning.
>
> The definition of the struct tagFOO actually ends with } FOO, *LPFOO; and the
> .pro file has
>
> void FCN (LPFOO b);
>
> so there's no struct tagFOO.  Adopting your interesting suggestion involves
> changing a lot of files, so I'd rather try to answer my original question.
>
> Is there a way to disable the warning?

You really want to go for sloppy code? There is a reason the
warning appears, even in the absence of any warning flags.
Perhaps it is more obvious when written out:

int foo(struct bla { int z; } q)
{
}

int foo(struct bla { double z; } q)
{
}

And the warning just tells you that the scope of struct bla is
within the parameter list. It does not even apply to
within the function. Yes, even if in a header file.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux