sohan123 has asked for the wisdom of the Perl Monks concerning the following question:

I am new to Perl XS programming. I am passing void** as one of the argument to Perl XS subroutine but it fails saying "Error: 'void **' not in typemap". Could you please let me know what should be added in typemap to get it work?

Replies are listed 'Best First'.
Re: Typemap in Perl XS (no)
by tye (Sage) on Aug 14, 2012 at 13:47 UTC

    No. 'void **' could actually mean any number of things.

    Is it supposed to be a pointer to the first item in an array of 'void *' values? Or is the array just one such pointer? What is/are the 'void *' pointer(s) supposed to be pointing at? How is the array or the thing(s) being pointed at supposed to be allocated? Initialized?

    What is your design for how to map between this 'void **' value in C and some Perl data structure?

    - tye        

      Thanks for the reply. My perl script is passing the address of a variable which will holds the string. The Perl XS program will populate the string and that string should then be available to perl script.
        Is your C API really using a char **? That would mean that library has its own memory allocator. There is no way to do a "char **" with the default perl typemap. You will have to write real C/XS code (CODE:/PPCODE:) section, or write real C code in your supplementary typemap in your module. ANSI prototype mode with default perl typemap wont work for "char **"s.

        Please read How do I post a question effectively? and post more background on what you are trying to do, and code or C header examples of what you have done so far.

        That sounds like 'char *' not 'void **'.

        You need to be clearer on how "the string" should be allocated, at least.

        - tye