Fixed bug 2121 - GCC throws error on SDL_FORCE_INLINE when compiling with -ansi

This commit is contained in:
Sam Lantinga 2013-09-30 22:35:32 -07:00
parent 22a972a440
commit 69a4351eb0
5 changed files with 23 additions and 19 deletions

View File

@ -99,11 +99,9 @@
#endif #endif
#endif /* Compiler needs structure packing set */ #endif /* Compiler needs structure packing set */
#ifndef __inline__
/* Set up compiler-specific options for inlining functions */ /* Set up compiler-specific options for inlining functions */
#ifndef SDL_INLINE_OKAY #ifndef SDL_INLINE_OKAY
#ifdef __GNUC__
#define SDL_INLINE_OKAY
#else
/* Add any special compiler-specific cases here */ /* Add any special compiler-specific cases here */
#if defined(_MSC_VER) || defined(__BORLANDC__) || \ #if defined(_MSC_VER) || defined(__BORLANDC__) || \
defined(__DMC__) || defined(__SC__) || \ defined(__DMC__) || defined(__SC__) || \
@ -112,31 +110,34 @@
#ifndef __inline__ #ifndef __inline__
#define __inline__ __inline #define __inline__ __inline
#endif #endif
#define SDL_INLINE_OKAY #define SDL_INLINE_OKAY 1
#else #else
#if !defined(__MRC__) && !defined(_SGI_SOURCE) #if !defined(__MRC__) && !defined(_SGI_SOURCE)
#ifndef __inline__ #ifndef __inline__
#define __inline__ inline #define __inline__ inline
#endif #endif
#define SDL_INLINE_OKAY #define SDL_INLINE_OKAY 1
#endif /* Not a funky compiler */ #endif /* Not a funky compiler */
#endif /* Visual C++ */ #endif /* Visual C++ */
#endif /* GNU C */
#endif /* SDL_INLINE_OKAY */ #endif /* SDL_INLINE_OKAY */
/* If inlining isn't supported, remove "__inline__", turning static /* If inlining isn't supported, remove "__inline__", turning static
inlined functions into static functions (resulting in code bloat inlined functions into static functions (resulting in code bloat
in all files which include the offending header files) in all files which include the offending header files)
*/ */
#ifndef SDL_INLINE_OKAY #if !SDL_INLINE_OKAY || __STRICT_ANSI__
#ifdef __inline__
#undef __inline__
#endif
#define __inline__ #define __inline__
#endif #endif
#endif /* __inline__ not defined */
#ifndef SDL_FORCE_INLINE #ifndef SDL_FORCE_INLINE
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define SDL_FORCE_INLINE __forceinline #define SDL_FORCE_INLINE __forceinline
#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
#define SDL_FORCE_INLINE __attribute__((always_inline)) static inline #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
#else #else
#define SDL_FORCE_INLINE static __inline__ #define SDL_FORCE_INLINE static __inline__
#endif #endif

View File

@ -73,9 +73,9 @@ SDL_GetPrefPath(const char *org, const char *app)
NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
char *retval = NULL; char *retval = NULL;
(void) org; // unused on Mac OS X and iOS. (void) org; /* unused on Mac OS X and iOS. */
if ([array count] > 0) { // we only want the first item in the list. if ([array count] > 0) { /* we only want the first item in the list. */
NSString *str = [array objectAtIndex:0]; NSString *str = [array objectAtIndex:0];
const char *base = [str UTF8String]; const char *base = [str UTF8String];
if (base) { if (base) {

View File

@ -33,7 +33,9 @@
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
static inline void Cocoa_ToggleMenuBar(const BOOL show)
static void
Cocoa_ToggleMenuBar(const BOOL show)
{ {
/* !!! FIXME: keep an eye on this. /* !!! FIXME: keep an eye on this.
* ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries. * ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
@ -57,7 +59,7 @@ static inline void Cocoa_ToggleMenuBar(const BOOL show)
#define MAC_OS_X_VERSION_MIN_REQUIRED 1050 #define MAC_OS_X_VERSION_MIN_REQUIRED 1050
#endif #endif
static inline BOOL static BOOL
IS_SNOW_LEOPARD_OR_LATER(_THIS) IS_SNOW_LEOPARD_OR_LATER(_THIS)
{ {
#if FORCE_OLD_API #if FORCE_OLD_API
@ -179,7 +181,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
return SDL_TRUE; return SDL_TRUE;
} }
static inline void static void
Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
{ {
if (IS_SNOW_LEOPARD_OR_LATER(_this)) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
@ -187,7 +189,7 @@ Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
} }
} }
static inline void static void
Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
{ {
if (IS_SNOW_LEOPARD_OR_LATER(_this)) { if (IS_SNOW_LEOPARD_OR_LATER(_this)) {

View File

@ -82,8 +82,8 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape
data->saved = SDL_FALSE; data->saved = SDL_FALSE;
} }
//[data->context saveGraphicsState]; /*[data->context saveGraphicsState];*/
//data->saved = SDL_TRUE; /*data->saved = SDL_TRUE;*/
[NSGraphicsContext setCurrentContext:data->context]; [NSGraphicsContext setCurrentContext:data->context];
[[NSColor clearColor] set]; [[NSColor clearColor] set];

View File

@ -44,7 +44,7 @@
static Uint32 s_moveHack; static Uint32 s_moveHack;
static __inline__ void ConvertNSRect(NSRect *r) static void ConvertNSRect(NSRect *r)
{ {
r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
} }
@ -920,8 +920,9 @@ Cocoa_RaiseWindow(_THIS, SDL_Window * window)
SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata); SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
NSWindow *nswindow = windowData->nswindow; NSWindow *nswindow = windowData->nswindow;
// makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing
// a minimized or hidden window, so check for that before showing it. a minimized or hidden window, so check for that before showing it.
*/
[windowData->listener pauseVisibleObservation]; [windowData->listener pauseVisibleObservation];
if (![nswindow isMiniaturized] && [nswindow isVisible]) { if (![nswindow isMiniaturized] && [nswindow isVisible]) {
[nswindow makeKeyAndOrderFront:nil]; [nswindow makeKeyAndOrderFront:nil];