On Tue, Jun 13, 2023 at 07:54:25PM -0700, Paul Eggert wrote: > I don't see how you could implement __has_include_next(<stdckdint.h>) for > arbitrary non-GCC compilers, which is what we'd need for glibc users. For > glibc internals we can use "#include_next" more readily, since we assume a > new-enough GCC. I.e. we could do something like this:
Indeed, limits.h uses #if defined __GNUC__ && !defined _GCC_LIMITS_H_ /* `_GCC_LIMITS_H_' is what GCC's file defines. */ # include_next <limits.h> #endif I'd just do: #if defined (__has_include_next) && !defined (ckd_add) # if __has_include_next (<stdckdint.h>) # include_next <stdckdint.h> # endif #endif and then deal with the fallback (if the C library really needs one, does it need to support a C23 feature in arbitrary compiler which doesn't support C23?). A fallback should start with using __builtin_{add,sub,mul}_overflow without extra checking if compiler supports it, with or without use of __has_builtin. GCC 6 and later has __builtin_{add,sub,mul}_overflow, only GCC 10 has __has_builtin, I think clang has added those shortly after they were added in GCC 6 (though, __builtin_{add,sub,mul}_overflow_p which has been added in GCC 7 wasn't added to clang). Jakub