Open ryandesign opened 2 years ago
In the 10.6 SDK, TargetConditionals.h defined fewer constants:
TARGET_OS_*
These conditionals specify in which Operating System the generated code will
run. The MAC/WIN32/UNIX conditionals are mutually exclusive. The EMBEDDED/IPHONE
conditionals are variants of TARGET_OS_MAC.
TARGET_OS_MAC - Generate code will run under Mac OS
TARGET_OS_WIN32 - Generate code will run under 32-bit Windows
TARGET_OS_UNIX - Generate code will run under some non Mac OS X unix
TARGET_OS_EMBEDDED - Generate code will run under an embedded OS variant
of TARGET_OS_MAC
TARGET_OS_IPHONE - Generate code will run under iPhone OS which
is a variant of TARGET_OS_MAC.
With all this in mind, here's one possible solution:
Software that includes tidy.h fails to compile on old OS versions like Mac OS X 10.6 when using a new compiler like clang 11:
Here is a full build log.
The problem is that clang 11 now considers undefined
TARGET_OS_*
constants to be an error whereas previous versions of clang did not. tidyplatform.h checks variousTARGET_OS_*
constants which did not exist back when Mac OS X 10.6 was created and which are not defined in the Mac OS X 10.6 SDK's TargetConditionals.h:I don't know why you need to define a
PLATFORM_NAME
, but if you do, I suggest you check if a constant is defined before you check its value to avoid the error, e.g.:You're also using
TARGET_OS_MAC
wrong.TARGET_OS_MAC
means any Apple Darwin-based operating system, including macOS, iOS, iPadOS, tvOS, watchOS. The macOS 11.1 SDK's TargetConditionals.h contains this explanation of the various constants:So if you want to know specifically if you're on macOS, you could check
TARGET_OS_OSX
, except that again that constant does not exist on Mac OS X 10.6. So my suggestion would be to check for iOS and tvOS and watchOS and if it's none of those then it's macOS. I suppose it is unlikely that tidy would ever be running under bridgeOS so you may not need to bother checking that.