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

Gilbert, Joseph T. jgilbert at tigr.ORG
Tue May 30 16:23:07 CEST 2006


MSVC doesn't generate the same compiler warnings. The projectfiles still generate a TON of warnings but they're not the same things that gcc puts out. The unused 'self' variable warning doesn't show up in the VC compiler. (at least not at it's current warnings lvl). Adding code like UNUSED(x) would be extremely strange imho since windows doesn't even generate this warning. 

The only reliable way on the vc compiler versions is to suppress warnings is by inserting the #pragma <warning> code into the files that are throwing warnings. In theory you can insert warning suppresion into the projectfiles, but this seems to be buggy on some versions. 

For example when you compile vpaint.c in the /src you get:

vpaint.c
\blender\source\blender\src\vpaint.c(107) : warning C4305: 'initializing' : truncation from 'double' to 'float'
\blender\source\blender\src\vpaint.c(108) : warning C4305: 'initializing' : truncation from 'double' to 'float'
\blender\source\blender\src\vpaint.c(126) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(128) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(130) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(132) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(376) : warning C4047: 'initializing' : 'unsigned int' differs in levels of indirection from 'void *'
\blender\source\blender\src\vpaint.c(376) : warning C4047: 'initializing' : 'unsigned int' differs in levels of indirection from 'void *'
\blender\source\blender\src\vpaint.c(376) : warning C4047: 'initializing' : 'unsigned int' differs in levels of indirection from 'void *'
\blender\source\blender\src\vpaint.c(376) : warning C4047: 'initializing' : 'unsigned int' differs in levels of indirection from 'void *'
\blender\source\blender\src\vpaint.c(376) : warning C4047: 'initializing' : 'unsigned int' differs in levels of indirection from 'void *'
\blender\source\blender\src\vpaint.c(498) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(778) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(779) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(782) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(783) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(792) : warning C4244: 'function' : conversion from 'float' to 'short', possible loss of data
\blender\source\blender\src\vpaint.c(792) : warning C4244: 'function' : conversion from 'float' to 'short', possible loss of data
\blender\source\blender\src\vpaint.c(801) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(834) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(835) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(840) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(843) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(855) : warning C4244: '*=' : conversion from 'double' to 'int', possible loss of data
\blender\source\blender\src\vpaint.c(1088) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(1092) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(1096) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
\blender\source\blender\src\vpaint.c(1101) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data

even with a very lax warnings lvl. 
This could be solved by adding:

#ifdef WIN32
#pragma warning( disable : 4244 4305 )
#endif

If you add this code it blendef.h (as an example) you resolve about 1200 warnings in the /src module.  

It's just an idea - but I'd like to see a warnings.h file to include which the above section of code with the correct mix of warnings to disable. My suggestions (and the ones that generate a number of issues for the windows build using the vc compiler) are at least:

warning C4305: 'identifier' : truncation from 'type1' to 'type2'
warning C4244: 'argument' : conversion from 'type1' to 'type2', possible loss of data

-----Original Message-----
From: bf-committers-bounces at projects.blender.org [mailto:bf-committers-bounces at projects.blender.org] On Behalf Of Ken Hughes
Sent: Monday, May 29, 2006 1:11 AM
To: bf-blender developers
Subject: Re: [Bf-committers] Re: Solution for suppressing "unused parameter"warnings?

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
_______________________________________________
Bf-committers mailing list
Bf-committers at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-committers


More information about the Bf-committers mailing list