My first guess would be that the XS case ends up loading two different instances of the library

Yes - I'll try to keep my mind open to that possibility as I plod on. Admittedly, I haven't provided very much for anyone ot work with - though I, myself, don't have much more to work with anyway.

I've written a basic Inline::C script (below my sig) that works fine. It has just 2 functions - namely wrap_eror_handler_off and demo2_e. The first turns off the error handling, and the second enables me to check that the error handling has, in fact, been turned off. (If the error handling is off, demo2_e returns a nan. Otherwise it dies most ungracefully with a 'domain error' from the gsl C library. This is all expected behaviour.)

And I've created a minimalist module (SIS::GSL) that contains the exact same 2 functions (nothing more, nothing less). The XS file that Inline::C generates, and the XS file that I have for SIS::GSL are *identical*, except that whereas Inline::C's XS file specifies:
MODULE = gsl_error_pl_4227 PACKAGE = main
SIS::GSL's XS file specifies:
MODULE = SIS::GSL PACKAGE = SIS::GSL
That's the only difference in the respective XS files. I've even gone so far as to rework SIS::GSL with the XS file containing:
MODULE = SIS::GSL PACKAGE = main
That successfully transfers wrap_eror_handler_off and demo2_e into the 'main' namespace, but wrap_eror_handler_off still fails to do what it is supposed to do.

Maybe I need to take a closer look at what the gsl library's gsl_set_error_handler_off is doing.

Thanks, tye.

Cheers,
Rob
use warnings; use strict; use Inline C => Config => #BUILD_NOISY => 1, #CLEAN_AFTER_BUILD => 0, INC => '-IC:/_32/msys/1.0/local/include', LIBS => '-LC:/_32/msys/1.0/local/lib -lgslcblas -lgsl'; use Inline C => <<'EOC'; #include <stdio.h> #include <gsl/gsl_math.h> #include <gsl/gsl_errno.h> #include <gsl/gsl_sf_gamma.h> #include <gsl/gsl_sf_coupling.h> #include <gsl/gsl_message.h> void wrap_error_handler_off() { gsl_set_error_handler_off(); } SV * demo2_e(int a1, int a2, int a3, int a4, int a5, int a6, int a7, i +nt a8, int a9) { gsl_sf_result r; gsl_sf_coupling_9j_e(a1, a2, a3, a4, a5, a6, a7, a8, a9, &r); return newSVnv(r.val); } EOC wrap_error_handler_off(); # '-2' is an invalid argument, so the following # returns a nan iff error handler is turned off. # Otherwise it dies with 'domain error' my $r = demo2_e(4, -2, 4, 3, 3, 2, 1, 1, 2); print $r, "\n";

In reply to Re^2: [XS] Bizarre (scoping ?) problem with wrapping C library function (2 dlls) by syphilis
in thread [XS] Bizarre (scoping ?) problem with wrapping C library function 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.