Search code examples
cmacosc-preprocessoros-detection

How to detect Mac OS X version using C preprocessor?


I want my C code to be compiled successfully on different versions of Mac OS X. One problem I have is before OS X Yosemite I need to #include <vecLib/clapack.h> to make lapack work. However, vecLib can't be founded on later versions.

How can I detect the version of Mac OS X and then include the header I have depending on the system?


Solution

  • include <Availability.h>
    
    #ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
    #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000
        #include <vecLib/clapack.h>
    #endif
    #endif