Excerpts from the mail message of Thomas Drake: ) ) I've created binding for a call that takes char** as argument. When my ) ..xs is translated, a XS_unpack_charPtrPtr appears. The symbol cannot be ) resolved at when I load the module. ) ) I am not able to locate XS_unpack_charPtrPtr anywhere. Someone ran into ) this problem not too long ago, but there was no response on the list. ) ) http:[EMAIL PROTECTED]/msg00160.html ) ) Does anyone know what to do in this situation.
What to do with a char** to translate between C and Perl varies widely depending on lots of things. If the API is simply using that parameter to return a pointer to a single '\0'-terminated string, then you can try switching the data type to char*&. In general, if you have pointers in XS then you have to carefully consider who is supposed to allocate, initialize, and free the memory and whether you want Perl to 1) simply keep track of the original pointer, 2) _copy_ the data into Perl data structures, or 3) have Perl allocate the memory (usually as a PV) and pass a pointer to that memory to the C API. (1) usually means that you can't do anything with the data directly in Perl (you have to write XS code to access or manipulate the data). (2) is less efficient and may not work if the API doesn't expect the data to be copied or wants to reuse an allocated structure in multiple calls. (3) is often not possible (not all APIs will let Perl allocate the memory). Which choice makes sense depends on details of the API that cannot be derived from just the data types involved. Therefore, XS cannot automatically figure out what to do when faced with pointers. A special case is made for char* where (2) is assumed (and '\0'-terminated strings are assumed), which isn't always the correct choice. If a pointer is simply used to pass an initialized value by reference, then use & instead of * and XS will do automatic translation to/from the base data type and simply pass that data by reference. Tye
