Best Practices for passing option hashes into XS

James Laver james.laver at gmail.com
Sun Apr 28 11:45:04 BST 2013


On 28 Apr 2013, at 01:55, Simon Wistow <simon at thegestalt.org> wrote:
> and then pass the HV into some C code. But I dislike having Perl types 
> in otherwise Perl free code.
> <snip>
> So my second thought is to have a struct
> 
> typedef struct {
>  char* first_opt;
>  char* second_opt;
> } foo_struct;

I think you've basically got a first question you haven't asked. Are you writing a C library that you want to interface with in perl or are you writing an XS library? If the former, you should probably translate them into a broader structure that includes all of the options you're looking for (or pass them as plain parameters into the remainder of the code). If the latter, you should stick with Perl datatypes.

James


More information about the london.pm mailing list