in reply to Re^3: XS: exposing C++ library constant as package variable
in thread XS: exposing C++ library constant as package variable

That suggests that get_sv() is returning an invalid SV*; which it shouldn't, if the docs are to be believed:

:) nope, its the call to SvIV_set thats causing it, solution i use is sv_setiv

SV* const_sv = get_sv( "Soivro::SOIVRO", GV_ADD ); sv_setiv( const_sv, FILENAME_MAX ); SvREADONLY_on( const_sv );
  • Comment on Re^4: XS: exposing C++ library constant as package variable ( sv_setiv , SvIV_set )
  • Download Code

Replies are listed 'Best First'.
Re^5: XS: exposing C++ library constant as package variable ( sv_setiv , SvIV_set )
by ikegami (Patriarch) on Oct 09, 2015 at 05:27 UTC

    It was crashing because you forgot to upgrade the scalar to one that has an IV slot before trying to change the IV slot. sv_setiv works because it performs the upgrade.

      Ah, now that is useful information; thanks. The Perl XS documentation was not very helpful in making it clear what the implicit preconditions for each function are, I'm afraid.

Re^5: XS: exposing C++ library constant as package variable ( sv_setiv , SvIV_set )
by BrowserUk (Patriarch) on Oct 08, 2015 at 23:44 UTC

    Thanks. Though it might have been better to address the information to the OP.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thanks. Though it might have been better to address the information to the OP.

      :) Maybe , but your node is why I poked at the problem, so thats where I put it

        Maybe , but your node is why I poked at the problem, so thats where I put it

        Cool. Thanks for poking!