Enable CERES_HAS_POSIX_BESSEL_FUNCTIONS on Apple platforms Commit 8b88a9ab49 guarded CERES_HAS_POSIX_BESSEL_FUNCTIONS in port.h with the glibc feature-test macros _SVID_SOURCE, _BSD_SOURCE, and _XOPEN_SOURCE. Because Apple libc++ does not implement C++17 special math functions and Darwin's <math.h> exposes j0, j1, and jn under __DARWIN_C_LEVEL >= 199506L rather than glibc feature-test macros, BesselJ0, BesselJ1, BesselJn, and TEST(Jet, Bessel) were silently disabled on macOS and iOS. Add __DARWIN_C_LEVEL >= 199506L and _DEFAULT_SOURCE (which replaced _BSD_SOURCE and _SVID_SOURCE in glibc 2.19) to the preprocessor check for CERES_HAS_POSIX_BESSEL_FUNCTIONS. Change-Id: I17a56983ae0b549346eaf3b5b3a993a6fcc4a3c3
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h index b74ca21..151d30e 100644 --- a/include/ceres/internal/port.h +++ b/include/ceres/internal/port.h
@@ -99,8 +99,15 @@ // including any standard library headers. Standard library Bessel functions are // preferred over any other implementation. #define CERES_HAS_CPP17_BESSEL_FUNCTIONS -#elif defined(_SVID_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) +#elif defined(_SVID_SOURCE) || defined(_BSD_SOURCE) || \ + defined(_DEFAULT_SOURCE) || defined(_XOPEN_SOURCE) || \ + (defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 199506L) // If defined, indicates that j0, j1, and jn from <math.h> are available. +// On glibc, these POSIX XSI extensions are exposed when _SVID_SOURCE, +// _BSD_SOURCE, _DEFAULT_SOURCE, or _XOPEN_SOURCE is defined. On Apple +// platforms (macOS, iOS), <math.h> does not use glibc feature-test macros +// and instead exposes j0, j1, and jn whenever __DARWIN_C_LEVEL >= 199506L +// (which holds by default under __DARWIN_C_FULL). #define CERES_HAS_POSIX_BESSEL_FUNCTIONS #endif