in reply to Re: [C Question] Determine if gcc provides erfl() function
in thread [C Question] Determine if gcc provides erfl() function

feature_test_macros is where it's at

I take it this means that erfl() is available if either:
a) the "-std=c99" flag is set; or
b) "_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L" is true.

And, if neither of those 2 conditions is met, then erfl() is unavailable.

Is that the correct way to read it ?

Update: If I #define _BSD_SOURCE at the beginning of LongDouble.xs, does this necessarily mean that erfl() is made available on these problem BSD systems ?

Cheers,
Rob
  • Comment on Re^2: [C Question] Determine if gcc provides erfl() function

Replies are listed 'Best First'.
Re^3: [C Question] Determine if gcc provides erfl() function
by Anonymous Monk on May 29, 2015 at 04:21 UTC

    Negative.

    On Linux/glibc, normally the _BSD_SOURCE, _SVID_SOURCE, _POSIX_SOURCE are on by default. See /usr/include/features.h. On ~BSD, some long double variants may be missing, or implemented as wrappers to a standard double function (with precision loss). Google around (for manpages and discussions). E.g. erfl() appears on FreeBSD 10.1 manpages, but not on 10.0. And no powl(). The sinhl/coshl/tanhl may be wrappers.

    I started up a decade-old FreeBSD 6.0 install; looking in libm.a (and libc.a), there is no erfl. The gcc-3.4.4 recognizes __builtin_erfl(), but this just defers to system erfl, and it fails to link.

    So, you're out of luck. Furthermore, (some) tests for availability ought to verify the precision, too.

Re^3: [C Question] Determine if gcc provides erfl() function
by RichardK (Parson) on May 29, 2015 at 09:26 UTC

    The man page for feature_test_macros has lots of details on how to use these, and the info page has even more.

    But the easiest way is to set the compiler command line option -std=c99 to ensure that everything (compiler/libc) complies with the C99 standard.

      While those functions are, indeed, a normative part of ISO C99 standard, it unfortunately does not follow that passing an option to gcc might cause a fully compliant environment to magically spring into existence.

      OP is concerned about BSD systems; a reference to glibc manpages is simply misguided.