From d71c32b9e889b045a9b0ad2a2c700f6b7b932e59 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 8 Apr 2013 18:37:50 -0400 Subject: [PATCH] More const_cast fixes for C++ apps using the public headers (thanks, Martin!). --- include/SDL_stdinc.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 746a39d44..a19647729 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -502,7 +502,13 @@ SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); } extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); #ifdef HAVE_STRCHR -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return (char*)strchr(str, c); } +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { +#ifdef __cplusplus +return const_cast(strchr(str, c)); +#else +return (char*)strchr(str, c); +#endif +} #define SDL_strchr SDL_strchr_inline #elif defined(HAVE_INDEX) /* !!! FIXME: is there anywhere that has this but not strchr? */ SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); } @@ -532,7 +538,13 @@ return (char*)rindex(str, c); extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); #ifdef HAVE_STRSTR -SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return (char*)strstr(haystack, needle); } +SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { +#ifdef __cplusplus +return const_cast(strstr(haystack, needle)); +#else +return (char*)strstr(haystack, needle); +#endif +} #define SDL_strstr SDL_strstr_inline #endif