Skip to content

Commit

Permalink
Fixed #4475
Browse files Browse the repository at this point in the history
-Wundef errors from clang-11.1 when targeting macOS

Targeting i386 against 10.8 SDK:

In file included from src/SDL_assert.c:21:
In file included from src/./SDL_internal.h:52:
In file included from include/SDL_config.h:33:
include/SDL_platform.h:73:5: error: 'TARGET_OS_TV' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    ^
1 error generated.

src/joystick/iphoneos/SDL_mfijoystick.m:38:5: error: 'TARGET_OS_IOS' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    ^
src/joystick/iphoneos/SDL_mfijoystick.m:460:5: error: 'TARGET_OS_TV' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
    ^
2 errors generated.

src/filesystem/cocoa/SDL_sysfilesystem.m:83:6: error: 'TARGET_OS_TV' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
     ^
1 error generated.

Targeting x86_64 against 10.12 SDK:

src/video/SDL_video.c:1492:25: error: 'TARGET_OS_MACCATALYST' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
                        ^
1 error generated.
  • Loading branch information
slouken committed Jul 8, 2021
1 parent 16e3bfe commit 1709242
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/SDL_platform.h
Expand Up @@ -70,6 +70,24 @@
/* lets us know what version of Mac OS X we're compiling on */
#include "AvailabilityMacros.h"
#include "TargetConditionals.h"

/* Fix building with older SDKs that don't define these
See this for more information:
https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
*/
#ifndef TARGET_OS_MACCATALYST
#define TARGET_OS_MACCATALYST 0
#endif
#ifndef TARGET_OS_IOS
#define TARGET_OS_IOS 0
#endif
#ifndef TARGET_OS_IPHONE
#define TARGET_OS_IPHONE 0
#endif
#ifndef TARGET_OS_TV
#define TARGET_OS_TV 0
#endif

#if TARGET_OS_TV
#undef __TVOS__
#define __TVOS__ 1
Expand Down

0 comments on commit 1709242

Please sign in to comment.