Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: [C Question] Determine if gcc provides erfl() function

by RichardK (Parson)
on May 28, 2015 at 14:50 UTC ( [id://1128146]=note: print w/replies, xml ) Need Help??


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

The help for erfl on my linux box says this :-

Feature Test Macro Requirements for glibc (see feature_test_macros( +7)): erf(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOU +RCE || _POSIX_C_SOURCE >= 200112L; or cc -std=c99 erff(), erfl(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISO +C99_SOURCE || _POSIX_C_SOURCE >= 200112L; or cc -std=c99

so feature_test_macros is where it's at :)

Replies are listed 'Best First'.
Re^2: [C Question] Determine if gcc provides erfl() function
by syphilis (Archbishop) on May 29, 2015 at 02:17 UTC
    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

      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.

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128146]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found