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

Jean-Luc Peurière jlp at nerim.net
Sun May 28 23:45:51 CEST 2006


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.

__attrivute__ 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

JLuc


More information about the Bf-committers mailing list