include/SDL_stdinc.h
changeset 8464 a2a909304cfe
parent 8460 f483e8bdae3c
parent 7076 1666f7a7494e
child 8477 ad08f0d710f3
     1.1 --- a/include/SDL_stdinc.h	Tue Apr 16 23:40:03 2013 -0400
     1.2 +++ b/include/SDL_stdinc.h	Sun Apr 21 12:38:44 2013 -0400
     1.3 @@ -100,9 +100,11 @@
     1.4  #ifdef __cplusplus
     1.5  #define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
     1.6  #define SDL_static_cast(type, expression) static_cast<type>(expression)
     1.7 +#define SDL_const_cast(type, expression) const_cast<type>(expression)
     1.8  #else
     1.9  #define SDL_reinterpret_cast(type, expression) ((type)(expression))
    1.10  #define SDL_static_cast(type, expression) ((type)(expression))
    1.11 +#define SDL_const_cast(type, expression) ((type)(expression))
    1.12  #endif
    1.13  /*@}*//*Cast operators*/
    1.14  
    1.15 @@ -509,49 +511,25 @@
    1.16  
    1.17  extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
    1.18  #ifdef HAVE_STRCHR
    1.19 -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
    1.20 -#ifdef __cplusplus
    1.21 -return const_cast<char*>(strchr(str, c));
    1.22 -#else
    1.23 -return (char*)strchr(str, c);
    1.24 -#endif
    1.25 -}
    1.26 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
    1.27  #define SDL_strchr SDL_strchr_inline
    1.28  #elif defined(HAVE_INDEX)  /* !!! FIXME: is there anywhere that has this but not strchr? */
    1.29 -SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
    1.30 +SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
    1.31  #define SDL_strchr SDL_strchr_inline
    1.32  #endif
    1.33  
    1.34  extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
    1.35  #ifdef HAVE_STRRCHR
    1.36 -SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
    1.37 -#ifdef __cplusplus
    1.38 -return const_cast<char*>(strrchr(str, c));
    1.39 -#else
    1.40 -return (char*)strrchr(str, c);
    1.41 -#endif
    1.42 -}
    1.43 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
    1.44  #define SDL_strrchr SDL_strrchr_inline
    1.45  #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
    1.46 -SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
    1.47 -#ifdef __cplusplus
    1.48 -return const_cast<char*>(rindex(str, c));
    1.49 -#else
    1.50 -return (char*)rindex(str, c);
    1.51 -#endif
    1.52 -}
    1.53 +SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
    1.54  #define SDL_strrchr SDL_strrchr_inline
    1.55  #endif
    1.56  
    1.57  extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
    1.58  #ifdef HAVE_STRSTR
    1.59 -SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
    1.60 -#ifdef __cplusplus
    1.61 -return const_cast<char*>(strstr(haystack, needle));
    1.62 -#else
    1.63 -return (char*)strstr(haystack, needle);
    1.64 -#endif
    1.65 -}
    1.66 +SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
    1.67  #define SDL_strstr SDL_strstr_inline
    1.68  #endif
    1.69