Files
rgbds/include/hacks/__availability
Rangi 1f3985a164 Fix build compatibility for macOS 10.14 and below (#1280)
macOS 10.15 introduced full `std::filesystem::path` support.
Before that our use of it would cause the build to fail.
This was not caught because "-mmacosx-version-min=10.9" was only
being passed to clang++ for release builds.

This passes that flag in a new static CI test build, and introduces
a hack developed by @LIJI32 to silence the availability errors,
since we use features already available in macOS 10.9.

This means we are testing both "vanilla" building,
and building static binaries using the same configuration
as during release, which should help avoiding last-minute
surprises.
2023-12-29 22:47:11 +01:00

33 lines
1.7 KiB
Plaintext

/* SPDX-License-Identifier: MIT */
#ifdef __APPLE__
#include_next <__availability>
/**
* This is a hack to make RGBDS build on macOS 10.14 and below. Without it, we get errors like:
* error: 'path' is unavailable: introduced in macOS 10.15
* The hack weakens the `std::filesystem::path` availability error into a warning, by removing
* `strict` from the availability macros (for information on the `availability` attribute, see
* https://releases.llvm.org/17.0.1/tools/clang/docs/AttributeReference.html#availability). This is
* acceptable because what we need of `std::filesystem::path` was already supported in macOS 10.14
* (the last version to support 32-bit, hence in demand despite being superseded by 10.15 in 2019).
*/
#ifndef _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
# undef _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
_Pragma("clang attribute push(__attribute__((availability(macosx,introduced=10.15))), apply_to=any(function,record))") \
_Pragma("clang attribute push(__attribute__((availability(ios,introduced=13.0))), apply_to=any(function,record))") \
_Pragma("clang attribute push(__attribute__((availability(tvos,introduced=13.0))), apply_to=any(function,record))") \
_Pragma("clang attribute push(__attribute__((availability(watchos,introduced=6.0))), apply_to=any(function,record))")
# define _LIBCPP_AVAILABILITY_FILESYSTEM \
__attribute__((availability(macosx,introduced=10.15))) \
__attribute__((availability(ios,introduced=13.0))) \
__attribute__((availability(tvos,introduced=13.0))) \
__attribute__((availability(watchos,introduced=6.0)))
#endif
#endif // __APPLE__