Fixed bug 2121 - GCC throws error on SDL_FORCE_INLINE when compiling with -ansi
authorSam Lantinga <slouken@libsdl.org>
Mon, 30 Sep 2013 22:35:32 -0700
changeset 77714434498bf4b9
parent 7770 28031e0042b2
child 7772 6b3cc8b7c589
Fixed bug 2121 - GCC throws error on SDL_FORCE_INLINE when compiling with -ansi
include/begin_code.h
src/filesystem/cocoa/SDL_sysfilesystem.m
src/video/cocoa/SDL_cocoamodes.m
src/video/cocoa/SDL_cocoashape.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/include/begin_code.h	Mon Sep 30 22:16:14 2013 -0700
     1.2 +++ b/include/begin_code.h	Mon Sep 30 22:35:32 2013 -0700
     1.3 @@ -99,11 +99,9 @@
     1.4  #endif
     1.5  #endif /* Compiler needs structure packing set */
     1.6  
     1.7 +#ifndef __inline__
     1.8  /* Set up compiler-specific options for inlining functions */
     1.9  #ifndef SDL_INLINE_OKAY
    1.10 -#ifdef __GNUC__
    1.11 -#define SDL_INLINE_OKAY
    1.12 -#else
    1.13  /* Add any special compiler-specific cases here */
    1.14  #if defined(_MSC_VER) || defined(__BORLANDC__) || \
    1.15      defined(__DMC__) || defined(__SC__) || \
    1.16 @@ -112,31 +110,34 @@
    1.17  #ifndef __inline__
    1.18  #define __inline__  __inline
    1.19  #endif
    1.20 -#define SDL_INLINE_OKAY
    1.21 +#define SDL_INLINE_OKAY 1
    1.22  #else
    1.23  #if !defined(__MRC__) && !defined(_SGI_SOURCE)
    1.24  #ifndef __inline__
    1.25  #define __inline__ inline
    1.26  #endif
    1.27 -#define SDL_INLINE_OKAY
    1.28 +#define SDL_INLINE_OKAY 1
    1.29  #endif /* Not a funky compiler */
    1.30  #endif /* Visual C++ */
    1.31 -#endif /* GNU C */
    1.32  #endif /* SDL_INLINE_OKAY */
    1.33  
    1.34  /* If inlining isn't supported, remove "__inline__", turning static
    1.35     inlined functions into static functions (resulting in code bloat
    1.36     in all files which include the offending header files)
    1.37  */
    1.38 -#ifndef SDL_INLINE_OKAY
    1.39 +#if !SDL_INLINE_OKAY || __STRICT_ANSI__
    1.40 +#ifdef __inline__
    1.41 +#undef __inline__
    1.42 +#endif
    1.43  #define __inline__
    1.44  #endif
    1.45 +#endif /* __inline__ not defined */
    1.46  
    1.47  #ifndef SDL_FORCE_INLINE
    1.48  #if defined(_MSC_VER)
    1.49  #define SDL_FORCE_INLINE __forceinline
    1.50  #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
    1.51 -#define SDL_FORCE_INLINE __attribute__((always_inline)) static inline
    1.52 +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
    1.53  #else
    1.54  #define SDL_FORCE_INLINE static __inline__
    1.55  #endif
     2.1 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m	Mon Sep 30 22:16:14 2013 -0700
     2.2 +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m	Mon Sep 30 22:35:32 2013 -0700
     2.3 @@ -73,9 +73,9 @@
     2.4      NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
     2.5      char *retval = NULL;
     2.6  
     2.7 -    (void) org;  // unused on Mac OS X and iOS.
     2.8 +    (void) org;  /* unused on Mac OS X and iOS. */
     2.9  
    2.10 -    if ([array count] > 0) {  // we only want the first item in the list.
    2.11 +    if ([array count] > 0) {  /* we only want the first item in the list. */
    2.12          NSString *str = [array objectAtIndex:0];
    2.13          const char *base = [str UTF8String];
    2.14          if (base) {
     3.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Mon Sep 30 22:16:14 2013 -0700
     3.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Mon Sep 30 22:35:32 2013 -0700
     3.3 @@ -33,7 +33,9 @@
     3.4  /* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
     3.5  #include <AvailabilityMacros.h>
     3.6  
     3.7 -static inline void Cocoa_ToggleMenuBar(const BOOL show)
     3.8 +
     3.9 +static void
    3.10 +Cocoa_ToggleMenuBar(const BOOL show)
    3.11  {
    3.12      /* !!! FIXME: keep an eye on this.
    3.13       * ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
    3.14 @@ -57,7 +59,7 @@
    3.15  #define MAC_OS_X_VERSION_MIN_REQUIRED 1050
    3.16  #endif
    3.17  
    3.18 -static inline BOOL
    3.19 +static BOOL
    3.20  IS_SNOW_LEOPARD_OR_LATER(_THIS)
    3.21  {
    3.22  #if FORCE_OLD_API
    3.23 @@ -179,7 +181,7 @@
    3.24      return SDL_TRUE;
    3.25  }
    3.26  
    3.27 -static inline void
    3.28 +static void
    3.29  Cocoa_ReleaseDisplayMode(_THIS, const void *moderef)
    3.30  {
    3.31      if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
    3.32 @@ -187,7 +189,7 @@
    3.33      }
    3.34  }
    3.35  
    3.36 -static inline void
    3.37 +static void
    3.38  Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist)
    3.39  {
    3.40      if (IS_SNOW_LEOPARD_OR_LATER(_this)) {
     4.1 --- a/src/video/cocoa/SDL_cocoashape.m	Mon Sep 30 22:16:14 2013 -0700
     4.2 +++ b/src/video/cocoa/SDL_cocoashape.m	Mon Sep 30 22:35:32 2013 -0700
     4.3 @@ -82,8 +82,8 @@
     4.4          data->saved = SDL_FALSE;
     4.5      }
     4.6  
     4.7 -    //[data->context saveGraphicsState];
     4.8 -    //data->saved = SDL_TRUE;
     4.9 +    /*[data->context saveGraphicsState];*/
    4.10 +    /*data->saved = SDL_TRUE;*/
    4.11      [NSGraphicsContext setCurrentContext:data->context];
    4.12  
    4.13      [[NSColor clearColor] set];
     5.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Sep 30 22:16:14 2013 -0700
     5.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Sep 30 22:35:32 2013 -0700
     5.3 @@ -44,7 +44,7 @@
     5.4  
     5.5  static Uint32 s_moveHack;
     5.6  
     5.7 -static __inline__ void ConvertNSRect(NSRect *r)
     5.8 +static void ConvertNSRect(NSRect *r)
     5.9  {
    5.10      r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    5.11  }
    5.12 @@ -920,8 +920,9 @@
    5.13      SDL_WindowData *windowData = ((SDL_WindowData *) window->driverdata);
    5.14      NSWindow *nswindow = windowData->nswindow;
    5.15  
    5.16 -    // makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing
    5.17 -    // a minimized or hidden window, so check for that before showing it.
    5.18 +    /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing
    5.19 +       a minimized or hidden window, so check for that before showing it.
    5.20 +     */
    5.21      [windowData->listener pauseVisibleObservation];
    5.22      if (![nswindow isMiniaturized] && [nswindow isVisible]) {
    5.23          [nswindow makeKeyAndOrderFront:nil];