Corrected some stdinc inline functions (thanks, Martin!).
authorRyan C. Gordon <icculus@icculus.org>
Thu, 04 Apr 2013 11:35:22 -0400
changeset 7057 c1563f514b5b
parent 7056 a5699778d80f
child 7058 64a2c8c882e1
Corrected some stdinc inline functions (thanks, Martin!). qsort() returns void, so remove the "return" keyword, plus some C++ const_casting magic. Fixes Bugzilla #1785.
include/SDL_stdinc.h
--- a/include/SDL_stdinc.h	Wed Apr 03 16:48:23 2013 -0700
+++ b/include/SDL_stdinc.h	Thu Apr 04 11:35:22 2013 -0400
@@ -30,7 +30,6 @@
 
 #include "SDL_config.h"
 
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -282,7 +281,7 @@
 
 extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));
 #ifdef HAVE_QSORT
-SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { return qsort(base, nmemb, size, compare); }
+SDL_FORCE_INLINE void SDL_qsort_inline(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) { qsort(base, nmemb, size, compare); }
 #define SDL_qsort SDL_qsort_inline
 #endif
 
@@ -512,10 +511,22 @@
 
 extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
 #ifdef HAVE_STRRCHR
-SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return (char*)strrchr(str, c); }
+SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
+#ifdef __cplusplus
+return const_cast<char*>(strrchr(str, c));
+#else
+return (char*)strrchr(str, c);
+#endif
+}
 #define SDL_strrchr SDL_strrchr_inline
 #elif defined(HAVE_RINDEX)  /* !!! FIXME: is there anywhere that has this but not strrchr? */
-SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return (char*)rindex(str, c); }
+SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
+#ifdef __cplusplus
+return const_cast<char*>(rindex(str, c));
+#else
+return (char*)rindex(str, c);
+#endif
+}
 #define SDL_strrchr SDL_strrchr_inline
 #endif