More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
authorRyan C. Gordon <icculus@icculus.org>
Mon, 08 Apr 2013 18:37:50 -0400
changeset 7059cd194e03c1da
parent 7058 64a2c8c882e1
child 7060 9d96148c2e3e
More const_cast fixes for C++ apps using the public headers (thanks, Martin!).
include/SDL_stdinc.h
     1.1 --- a/include/SDL_stdinc.h	Fri Apr 05 16:34:59 2013 -0400
     1.2 +++ b/include/SDL_stdinc.h	Mon Apr 08 18:37:50 2013 -0400
     1.3 @@ -502,7 +502,13 @@
     1.4  
     1.5  extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
     1.6  #ifdef HAVE_STRCHR
     1.7 -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return (char*)strchr(str, c); }
     1.8 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
     1.9 +#ifdef __cplusplus
    1.10 +return const_cast<char*>(strchr(str, c));
    1.11 +#else
    1.12 +return (char*)strchr(str, c);
    1.13 +#endif
    1.14 +}
    1.15  #define SDL_strchr SDL_strchr_inline
    1.16  #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
    1.17  SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
    1.18 @@ -532,7 +538,13 @@
    1.19  
    1.20  extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
    1.21  #ifdef HAVE_STRSTR
    1.22 -SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return (char*)strstr(haystack, needle); }
    1.23 +SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
    1.24 +#ifdef __cplusplus
    1.25 +return const_cast<char*>(strstr(haystack, needle));
    1.26 +#else
    1.27 +return (char*)strstr(haystack, needle);
    1.28 +#endif
    1.29 +}
    1.30  #define SDL_strstr SDL_strstr_inline
    1.31  #endif
    1.32