Some questions regarding MacPorts legacy support package

Ryan Schmidt ryandesign at macports.org
Sun Jul 5 10:23:13 UTC 2020



On Jul 4, 2020, at 15:44, Jason Liu wrote:

> Question 2:
> 
> A related question is that in MacportsLegacySupport.h, you guys use version numbers such as 101300, 1070, etc. instead of the constants that are defined in AvailabilityMacros.h, such as MAC_OS_X_VERSION_10_13, MAC_OS_X_VERSION_10_7, etc. Is there any particular reason for not using the constants and going with the actual integer numbers? It looks like not even Apple's own source code is consistent with this. In AvailabilityMacros.h, they use the version number constants MAC_OS_X_VERSION_10_*, but in other header files like assert.h, pthread.h, etc., they use the raw integers, i.e. 1070.

Using the numbers is preferred. Once upon a time there was an Apple document stating that. Numbers will always work. The constants will only work if they are defined. MAC_OS_X_VERSION_10_13 for example is only defined in the 10.13 SDK and later, and if you reference an undefined constant, the preprocessor won't necessarily complain but will evaluate it to 0, which is probably not what you want.

Some projects use the constants and then have a central header where they check each constant to make sure it's defined and otherwise they define it themselves. This seems like a lot of work for no particular benefit to me. Just use the numbers. They're documented, they're clear, they're not changing.


More information about the macports-dev mailing list