From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/corecrt.h | 9 +++++++++ include/msvcrt/wchar.h | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/msvcrt/corecrt.h b/include/msvcrt/corecrt.h index 65357a13403..ae926394ad9 100644 --- a/include/msvcrt/corecrt.h +++ b/include/msvcrt/corecrt.h @@ -250,6 +250,15 @@ typedef int errno_t; #define _ERRNO_T_DEFINED #endif
+#ifndef _CONST_RETURN +# ifdef __cplusplus +# define _CONST_RETURN const +# define _CRT_CONST_CORRECT_OVERLOADS +# else +# define _CONST_RETURN +# endif +#endif + struct threadlocaleinfostruct; struct threadmbcinfostruct; typedef struct threadlocaleinfostruct *pthreadlocinfo; diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index 4ca189bd2c7..98167b59076 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -45,14 +45,22 @@ int __cdecl wctob(wint_t);
_ACRTIMP errno_t __cdecl wmemcpy_s(wchar_t *, size_t, const wchar_t *, size_t);
-static inline wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) +static inline _CONST_RETURN wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) { const wchar_t *end; for (end = s + n; s < end; s++) - if (*s == c) return (wchar_t*)s; + if (*s == c) return (_CONST_RETURN wchar_t *)s; return NULL; }
+#ifdef __cplusplus +extern "C++" inline wchar_t *wmemchr(wchar_t *s, wchar_t c, size_t n) +{ + wchar_t const* s_const = s; + return const_cast<wchar_t *>(wmemchr(s_const, c, n)); +} +#endif + static inline int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) { size_t i;