include: Cast-qual warnings fix using const_cast macro
Andrew Talbot
Andrew.Talbot at talbotville.com
Sat Dec 16 05:36:51 CST 2006
This patch may not get applied, but it does allow one to see a truer picture
of the remaining cast-qual warning violations, by removing the distortion
caused by some of the inlined functions in "unicode.h".
-- Andy.
---
Changelog:
include: Cast-qual warnings fix using const_cast macro.
diff -urN a/include/wine/unicode.h b/include/wine/unicode.h
--- a/include/wine/unicode.h 2006-12-16 10:33:52.000000000 +0000
+++ b/include/wine/unicode.h 2006-12-14 22:39:43.000000000 +0000
@@ -35,6 +35,12 @@
#define WINE_UNICODE_API DECLSPEC_IMPORT
#endif
+#ifdef __cplusplus
+#define const_cast(t, e) const_cast<t>(e)
+#else
+#define const_cast(t, e) (t)(ULONG_PTR)(e)
+#endif
+
/* code page info common to SBCS and DBCS */
struct cp_info
{
@@ -240,7 +246,7 @@
extern inline WCHAR *strchrW( const WCHAR *str, WCHAR ch );
extern inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
{
- do { if (*str == ch) return (WCHAR *)str; } while (*str++);
+ do { if (*str == ch) return const_cast(WCHAR *, str); } while (*str++);
return NULL;
}
@@ -248,14 +254,14 @@
extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch )
{
WCHAR *ret = NULL;
- do { if (*str == ch) ret = (WCHAR *)str; } while (*str++);
+ do { if (*str == ch) ret = const_cast(WCHAR *, str); } while (*str++);
return ret;
}
extern inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept );
extern inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept )
{
- for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)str;
+ for ( ; *str; str++) if (strchrW( accept, *str )) return const_cast(WCHAR *, str);
return NULL;
}
@@ -295,7 +301,7 @@
extern inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
{
const WCHAR *end;
- for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)ptr;
+ for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return const_cast(WCHAR *, ptr);
return NULL;
}
@@ -304,7 +310,7 @@
{
const WCHAR *end, *ret = NULL;
for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = ptr;
- return (WCHAR *)ret;
+ return const_cast(WCHAR *, ret);
}
extern inline long int atolW( const WCHAR *str );
More information about the wine-patches
mailing list