Can't compile code with __MAC_OS_X_VERSION_MIN_REQUIRED undefined

I've been using a code that pass -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ during compilation. The code was compiling well for a while. I haven't been using that project for a while, but recently found out that my project start failing to build with errors:

In file included from my_project/main_app.cpp:52:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_time.h:32:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/mach_types.h:109:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_region.h:47:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/machine/vm_param.h:33:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/vm_param.h:97:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/vm_page_size.h:59:44: error: expected ';' after top level declarator

extern  vm_size_t       vm_kernel_page_size     __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);

My /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h file contains

#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
...
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
...
#else
    #define __OSX_AVAILABLE_STARTING(_osx, _ios)
    #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep)
    #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg)
#endif

but the last #else case is never hit because /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h contains:

#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
    #if defined(__has_builtin) && __has_builtin(__is_target_os)
        #if __is_target_os(macos)
            #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
            #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2
        #endif
    #elif  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
        #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
        #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_14_2
    #endif /*  __has_builtin(__is_target_os) && __is_target_os(macos) */
#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */

So in combination with my initial -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ option the #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ produce an empty define.

So the question to apple developers: could you please update #elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ to #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)? Or even change #ifndef __MAC_OS_X_VERSION_MIN_REQUIRED to #if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)?

Otherwise the #else case in Availability.h described above does not make any sense.

Best regards, Petro

Replies

I've been using a code that pass -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ during compilation.

Why? What were you trying to achieve by passing in that option?

Also, it looks like you’re using Xcode. Is that right? If so, what version?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • I'm trying to build https://github.com/llvm/llvm-project/tree/main/libcxx in "bare metal simulation" mode. It is similar to cross compile by the actual target is x86 application. The LLVM libcxx relies on "ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED" in case of compiling on MAC. So I pass both "-U__APPLE__" and "-U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__".

    pkgutil --pkg-info=com.apple.pkg.CLTools_Executables package-id: com.apple.pkg.CLTools_Executables version: 15.1.0.0.1.1700200546

Add a Comment