diff options
author | rcombs <rcombs@rcombs.me> | 2023-02-28 03:20:04 -0600 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2023-08-21 04:11:54 +0300 |
commit | 847af2a1ce67cc2ac0db1252f41ee99ff724b05b (patch) | |
tree | 0b9ad26bfc37408a55a498969cb07243b6570c49 | |
parent | 4eff3a78483f7c956d1109d17fc3e070d06b2820 (diff) | |
download | libass-847af2a1ce67cc2ac0db1252f41ee99ff724b05b.tar.bz2 libass-847af2a1ce67cc2ac0db1252f41ee99ff724b05b.tar.xz |
ass_coretext: add CHECK_AVAILABLE as a more portable __builtin_available
This allows us to use weak symbols on older Clang and GCC
while guarding them with __builtin_available on newer Clang
to support -Werror=unguarded-availability.
-rw-r--r-- | libass/ass_coretext.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c index d2a837b..7009264 100644 --- a/libass/ass_coretext.c +++ b/libass/ass_coretext.c @@ -29,6 +29,18 @@ #include "ass_coretext.h" +#ifndef __has_builtin +#define __has_builtin 0 +#endif + +#if __has_builtin(__builtin_available) +#define CHECK_AVAILABLE(sym, ...) __builtin_available(__VA_ARGS__) +#else +// Cast to suppress "comparison never succeeds" warnings in some compilers +// when the build target is new enough that sym isn't a weak symbol +#define CHECK_AVAILABLE(sym, ...) (!!(intptr_t) &sym) +#endif + #define SAFE_CFRelease(x) do { if (x) CFRelease(x); } while (0) static const ASS_FontMapping font_substitutions[] = { |