Fixed bug 1363 - SDL 1.2 hg does not compile against the 10.5 SDK SDL-1.2
authorSam Lantinga
Thu, 05 Jan 2012 19:19:58 -0500
branchSDL-1.2
changeset 61586f3a2bb301d6
parent 6157 8a1bc41db6bb
child 6169 6f3e5ccfd585
Fixed bug 1363 - SDL 1.2 hg does not compile against the 10.5 SDK

Alexei Svitkine 2012-01-05 15:55:47 PST
Open SDL.xcodeproject and change SDK to 10.5 and try to build. It will fail.

There are two errors:

1. Incorrect SDK version check in src/cdrom/macosx/AudioFilePlayer.h, which
redefines FSIORefNum. FSIORefNum is actually defined in the 10.5 SDK, but not
in the 10.4 one.

2. Code in SDL_QuartzVideo.m that tries to access NSScreen's private _frame
ivar, which fails to link on 64-bit. See:
https://www.google.com/?q=%22_OBJC_IVAR_%24_NSScreen._frame%22

Attached patch fixes both of these problems.
src/cdrom/macosx/AudioFilePlayer.h
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/cdrom/macosx/AudioFilePlayer.h	Mon Jan 02 21:25:34 2012 -0800
     1.2 +++ b/src/cdrom/macosx/AudioFilePlayer.h	Thu Jan 05 19:19:58 2012 -0500
     1.3 @@ -37,7 +37,7 @@
     1.4  #include <AudioUnit/AUNTComponent.h>
     1.5  #endif
     1.6  
     1.7 -#if (MAC_OS_X_VERSION_MAX_ALLOWED <= 1050)
     1.8 +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1050)
     1.9  typedef SInt16 FSIORefNum;
    1.10  #endif
    1.11  
     2.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Mon Jan 02 21:25:34 2012 -0800
     2.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Thu Jan 05 19:19:58 2012 -0500
     2.3 @@ -36,7 +36,18 @@
     2.4      __IPHONE_NA, __IPHONE_NA);
     2.5  #endif
     2.6  
     2.7 -#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)  /* Fixed in Snow Leopard */
     2.8 +
     2.9 +static inline BOOL IS_LION_OR_LATER(_THIS)
    2.10 +{
    2.11 +    return (system_version >= 0x1070);
    2.12 +}
    2.13 +
    2.14 +static inline BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS)
    2.15 +{
    2.16 +    return (system_version >= 0x1060);
    2.17 +}
    2.18 +
    2.19 +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) && !defined(__LP64__)  /* Fixed in Snow Leopard */
    2.20  /*
    2.21      Add methods to get at private members of NSScreen. 
    2.22      Since there is a bug in Apple's screen switching code
    2.23 @@ -54,12 +65,14 @@
    2.24      _frame = frame;
    2.25  }
    2.26  @end
    2.27 -static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame)
    2.28 +static inline void QZ_SetFrame(_THIS, NSScreen *nsscreen, NSRect frame)
    2.29  {
    2.30 -    [nsscreen setFrame:frame];
    2.31 +    if (!IS_SNOW_LEOPARD_OR_LATER(this)) {
    2.32 +        [nsscreen setFrame:frame];
    2.33 +    }
    2.34  }
    2.35  #else
    2.36 -static inline void QZ_SetFrame(NSScreen *nsscreen, NSRect frame)
    2.37 +static inline void QZ_SetFrame(_THIS, NSScreen *nsscreen, NSRect frame)
    2.38  {
    2.39  }
    2.40  #endif
    2.41 @@ -125,16 +138,6 @@
    2.42  #  endif
    2.43  #endif
    2.44  
    2.45 -static inline BOOL IS_LION_OR_LATER(_THIS)
    2.46 -{
    2.47 -    return (system_version >= 0x1070);
    2.48 -}
    2.49 -
    2.50 -static inline BOOL IS_SNOW_LEOPARD_OR_LATER(_THIS)
    2.51 -{
    2.52 -    return (system_version >= 0x1060);
    2.53 -}
    2.54 -
    2.55  static void QZ_ReleaseDisplayMode(_THIS, const void *moderef)
    2.56  {
    2.57      /* we only own these references in the 10.6+ API. */
    2.58 @@ -607,7 +610,7 @@
    2.59                  See comment in QZ_SetVideoFullscreen for why we do this
    2.60              */
    2.61              screen_rect = NSMakeRect(0,0,device_width,device_height);
    2.62 -            QZ_SetFrame([ NSScreen mainScreen ], screen_rect);
    2.63 +            QZ_SetFrame(this, [ NSScreen mainScreen ], screen_rect);
    2.64          }
    2.65      }
    2.66      /* Release window mode resources */
    2.67 @@ -927,7 +930,7 @@
    2.68          ourselves. This hack should be removed if/when the bug is fixed.
    2.69      */
    2.70      screen_rect = NSMakeRect(0,0,width,height);
    2.71 -    QZ_SetFrame([ NSScreen mainScreen ], screen_rect);
    2.72 +    QZ_SetFrame(this, [ NSScreen mainScreen ], screen_rect);
    2.73  
    2.74      /* Save the flags to ensure correct tear-down */
    2.75      mode_flags = current->flags;