Carp provides for 'misreporting' the location of errors via $Carp::CarpLevel = 1;

Yep - that does it nicely. (After I posted the sopw I realised that particular question didn't have a real lot to do with "XS", "C doubles", or "-Duselongdouble" :-)

In that respect, when the XS code is compiled, the C compiler probably is yelling about it

Haven't noticed any complaints from gcc - even if the SvNV() is not explicitly cast to a double. On windows, with an MSVC-built perl, you aren't going to get a "proper" -Duselongdouble build of perl ... in that any Microsoft compiler that knows about long doubles will tell you that sizeof(long double) == sizeof(double) == 8.
With MinGW, it should be theoretically possible to build a -Duse64bitint and -Duselongdouble build of perl .... but since MinGW uses the msvcrt.dll runtime library, I don't think it would be possible for such a perl to printf() the long double values correctly.

I generally resort to adding an obviously fatal error at the end of the inline C

The idea of the use Inline C => Config => BUILD_NOISY => 1; is that it provides verbosity (including any compiler warnings), thus eliminating the need to take such measures.

It could attempt to detect whether the number of significant bits set in the mantissa of the long double exceeds 53

Yes - that's what I was trying to think of. It's just a matter of finding the position of the least significant (set) bit in the argument that's given to perl_foo(). It's the perl code (the 'perl_foo' function to be precise) that needs to determine whether there has been a loss of precision.

Thanks BrowserUk.

Cheers,
Rob

In reply to Re^2: XS, C doubles and -Duselongdouble by syphilis
in thread XS, C doubles and -Duselongdouble by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.