Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Corrected some stdinc inline functions (thanks, Martin!).
Browse files Browse the repository at this point in the history
qsort() returns void, so remove the "return" keyword, plus some C++
 const_casting magic.

 Fixes Bugzilla #1785.
  • Loading branch information
icculus committed Apr 4, 2013
1 parent 1f4224e commit 3371422
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions include/SDL_stdinc.h
Expand Up @@ -30,7 +30,6 @@

#include "SDL_config.h"


#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
Expand Down Expand Up @@ -282,7 +281,7 @@ SDL_FORCE_INLINE int SDL_setenv_inline(const char *name, const char *value, int

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

Expand Down Expand Up @@ -512,10 +511,22 @@ SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(

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

Expand Down

0 comments on commit 3371422

Please sign in to comment.