Hi,
i am currently trying to fix the -Wcast-qual warnings. In include/wine/unicode.h there a 4 function:
static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n) static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch ) static inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) static inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept )
whose signatures forces us to discard the const of an parameter while returning it as the function value. Compiling with -Wcast-qual gives (correctly) this warning:
../../include/wine/unicode.h:218: warning: cast discards qualifiers from pointer target type
Together these four functions account for a total of 1400 (!) warnings.
In samba_4 sourcecode i discovered the following macros, which are apparently a hack but silences these warnings:
#define discard_const(ptr) ((void *)((intptr_t)(ptr))) #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
an crude proof of concept is attached as a patch.
I am not sure how portable this solution is...
Any comments are welcome...
Regards, Stefan