Francois Gouget wrote:
What are these warnings? What is causing them?
Sorry, should have posted an explanation. The warning comes from code like this:
char foo(x); #define bar(x) (int) foo(x)
So for the example you gave from my patch:
#define Header_SetImageList(hwnd,himl) \ (HIMAGELIST)SNDMSGA((hwnd),HDM_SETIMAGELIST,0,(LPARAM)himl)
We get a "computed value is not used" warning when we use Header_SetImageList without assigning the returned value to anything.
I reported this in the gcc bugzilla some time ago, but the gcc team claim that this is a feature, not a bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25955
They would prefer that we use statement expressions, which are gcc specific, in our macros. Something like:
#define Header_SetImageList(hwnd,himl) \ ({ HIMAGELIST r; \ r = (HIMAGELIST)SNDMSGA((hwnd),HDM_SETIMAGELIST,0,(LPARAM)himl); \ r; })
Alexandre suggested that we use inline functions to solve this problem, however this requires including winuser.h when including windowsx.h, and that we choose SendMessageA or SendMessageW for the macros that deal with strings.
Conceivably we could use:
#ifdef HAVE_BORKED_GCC_COMPUTED_VALUE_NOT_USED_WARNING
#define Header_SetImageList(hwnd,himl) \ ({ HIMAGELIST r; \ r = (HIMAGELIST)SNDMSGA((hwnd),HDM_SETIMAGELIST,0,(LPARAM)himl); \ r; })
#else
#define Header_SetImageList(hwnd,himl) \ (HIMAGELIST)SNDMSGA((hwnd),HDM_SETIMAGELIST,0,(LPARAM)himl)
#endif
This requires use -DHAVE_BORKED_GCC_COMPUTED_VALUE_NOT_USED_WARNING when compiling Wine code and Winelib apps.
Do we really have to give up on the macros and use SendMessage directly to avoid the warnings? If we do, then I would say this means the macros are broken because it means Winelib users will get the same problem we do and will have to modify their code or live with gobs of warnings.
Yes, and it will be broken for WineLib. I quote Alexandre from IRC:
<julliard> mike_m: hmm right, that's a PITA <mike_m> truely <julliard> i'd say get rid of windowsx.h then
I agree this is not an ideal solution... let me know if you have any better ideas.
Mike