diff --git a/mdbx.h b/mdbx.h index 2a6a29d9..e3915991 100644 --- a/mdbx.h +++ b/mdbx.h @@ -218,10 +218,14 @@ typedef mode_t mdbx_mode_t; #ifndef __has_feature #define __has_feature(x) (0) +#define __has_exceptions_disabled (0) +#else +#define __has_exceptions_disabled \ + (__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions)) #endif /* __has_feature */ #ifndef __has_extension -#define __has_extension(x) (0) +#define __has_extension(x) __has_feature(x) #endif /* __has_extension */ #ifndef __has_builtin @@ -236,11 +240,13 @@ typedef mode_t mdbx_mode_t; * These functions should be declared with the attribute pure. */ #if defined(DOXYGEN) #define MDBX_PURE_FUNCTION [[gnu::pure]] -#elif __has_C23_or_CXX_attribute(gnu::pure) +#elif __has_C23_or_CXX_attribute(gnu::pure) && \ + (!defined(__apple_build_version__) || !defined(__clang_major__) || \ + __clang_major__ > 17) #define MDBX_PURE_FUNCTION [[gnu::pure]] #elif (defined(__GNUC__) || __has_attribute(__pure__)) && \ (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \ - !defined(__cplusplus) || !__has_feature(cxx_exceptions)) + !defined(__cplusplus) || __has_exceptions_disabled) #define MDBX_PURE_FUNCTION __attribute__((__pure__)) #else #define MDBX_PURE_FUNCTION @@ -278,11 +284,13 @@ typedef mode_t mdbx_mode_t; * It does not make sense for a const function to return void. */ #if defined(DOXYGEN) #define MDBX_CONST_FUNCTION [[gnu::const]] -#elif __has_C23_or_CXX_attribute(gnu::const) +#elif __has_C23_or_CXX_attribute(gnu::const) && \ + (!defined(__apple_build_version__) || !defined(__clang_major__) || \ + __clang_major__ > 17) #define MDBX_CONST_FUNCTION [[gnu::const]] #elif (defined(__GNUC__) || __has_attribute(__const__)) && \ (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || \ - !defined(__cplusplus) || !__has_feature(cxx_exceptions)) + !defined(__cplusplus) || __has_exceptions_disabled) #define MDBX_CONST_FUNCTION __attribute__((__const__)) #else #define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION