Cast-qual warnings: current status
Hi, Apart from any oversights, I have completed my run of cast-qual fixes for the "dlls" and "dlls/tests" directories. The one file that most distorts the picture when -Wcast-qual is applied is "unicode.h", since its wide-string functions are inlined and it is included quite widely. I have posted a patch (dated 16 Dec 2006, entitled "include: Cast-qual warnings fix using const_cast macro") that, if not accepted, you can apply locally, if you want to build with "-Wcast-qual" to see the extent of the remaining problem. For the places where we still must use casts, I propose the introduction of a macro that takes on the role of the "const_cast" in C++. My attempt at that is as follows. #ifdef __cplusplus #define const_cast(t, e) const_cast<t>(e) #else #define const_cast(t, e) (t)(ULONG_PTR)(e) #endif This will make its purpose stand out from those of other casts. So, for example, the definition of strchrW() would become: extern inline WCHAR *strchrW( const WCHAR *str, WCHAR ch ) { do { if (*str == ch) return const_cast(WCHAR *, str); } while (*str++); return NULL; } The positive point of aiming to add -Wcast-qual universally - I would argue - is that it lets the compiler watch out for inadvertent introductions of fresh violations, so I become redundant, and you proper programmers can concentrate on more interesting things. :) I invite you, please, to debate the above issues, so we can determine the way forward concerning this issue. Meanwhile, I shall move on to the few "programs" and "server" files that generate cast-qual warnings. Thanks, -- Andy.
participants (1)
-
Andrew Talbot