[Bf-committers] Re: Solution for suppressing "unused parameter" warnings?

Ken Hughes khughes at pacific.edu
Mon May 29 07:11:12 CEST 2006


Jean-Luc Peurière wrote:
> 
> Le 28 mai 06 à 18:41, Ken Hughes a écrit :
> 
>> Jean-Luc Peurière wrote:
>>
>>> Le 28 mai 06 à 01:20, Ed Halley a écrit :
>>>
>>>>
>>>> #define UNUSED(x)  { x = x; }
>>>>
>>>> int foo(int a, char* b, float c[3])
>>>> {
>>>>     UNUSED(a);
>>>>     UNUSED(b);
>>>>     UNUSED(c[0])
>>>>     return 0;
>>>> }
>>>
>>> not good from an optimisation point of view.
>>
>>
>> I agree that using the unused args just to shut up the compiler  isn't 
>> a great idea, especially if the compiler is smart enough to  know that 
>> the use does nothing and just created another warning.
>>
>>> you can either use the unused attribute (but that may not be  supported
>>> by all compilers), or pass the following compiling option to gcc :
>>> -Wno-unused-parameter
>>
>> That's the issue; is there a way we can shut it up for everybody,  not 
>> just gcc users?  Is the __attribute__ keyword supported by MS  and 
>> MacOS  compilers?
> 
> 
> MacOs compiler *IS* gcc so both works.

Oh... heh.  Learn something new every day.

> __attribute__ is gcc extension so unsafe everywhere else
> 
> the compiler option is the best as you can use platform specifics  
> options. dont know the windows one, but there is one for sure

Googling seems to indicate there's a way to do it with Windows (although 
I can't find it now), although it's a different mechanism.  Since I 
don't use Windows I can't experiment to test deeper.

So, at least for us gcc users out there, should we define a macro 
somewhere which at least shuts the compiler up for us?

Ken


More information about the Bf-committers mailing list