in reply to [OT: C] Getting pointers to functions

Why not be explicit and create the XS using Perl from the C header files? That way, you also avoid the problem of having different (C) signatures of the functions.

Doing that stuff explicitly allows you to more easily exclude functions that have special signatures from your generic approach later on.

  • Comment on Re: [OT: C] Getting pointers to functions

Replies are listed 'Best First'.
Re^2: [OT: C] Getting pointers to functions
by syphilis (Archbishop) on Dec 31, 2016 at 07:48 UTC
    Why not be explicit and create the XS using Perl from the C header files?

    IIUC, the suggestion here is to avoid passing pointers to functions around - which I think is generally good advice, but not applicable for this case (AFAICT).

    S you've also pointed out, the presence of different/special signatures is also an issue - but I think I can handle that acceptably by accommodating only those functions that take only mpfr_t arguments.
    (Hmmm ... except that I'll have to allow mpfr_strtofr which takes a "string" argument.)
    The real annoyance is not having simpler access to the function pointers.

    This is not a critical mission - but it's a bit interesting, and is taking me into areas of C that I've not visited before.
    I'll continue to play with it. Below my sig is a working example of where I've got to so far - but it requires Math::MPFR, a recent svn version of the mpfr library and a C99 compiler.

    Cheers,
    Rob