WINECFG: Eliminate some gcc 4.1 warnings caused by casts in macros.

Francois Gouget fgouget at
Fri Mar 3 08:29:43 CST 2006

On Fri, 3 Mar 2006, Mike McCormack wrote:
> They would prefer that we use statement expressions, which are gcc specific, 
> in our macros.  Something like:

Thanks for the explanation.
Sure, having an #ifdef/#else/#endif for each macro is way too painful. 
But what about the following:

+#ifndef WINE_CAST
+# if __GNUC__
+#  define WINE_CAST(ctype, val) ({ctype r=(ctype)(val);r;})
+# else
+#  define WINE_CAST(ctype, val) ((ctype)(val))
+# endif
+ #define Header_SetImageList(hwnd,himl) \

This pre-processes to code that uses the statement expression on gcc 
compilers and to the regular cast for others. So there should be no 
warning in either case (I couldn't check with gcc 4.1 but this 
preprocesses to the expected form). I also checked with gcc 2.95 and it 
compiles fine and without warning there which should be enough backwards 
compatibility for everyone (otherwise we can go further and check the 
GCC version).

Of course in a real patch the WINE_CAST macro would be declared 
somewhere in windef.h, and we'd still have to change all the macros that 
cast a function result. But that seems quite feasible and not too ugly 
and I would be willing to submit such a patch. We may also want to find 

Should I send such a patch?

Francois Gouget <fgouget at>    
                   In a world without fences who needs Gates?

More information about the wine-devel mailing list