views:

38

answers:

1

On OpenSolaris ($^O eq 'solaris', vers. 2.11), I'm trying to build an XS module which uses the XPGv4v2/Single Unix Spec. understanding of struct msghdr, specifically for "ancillary data" interrogation.

However, the native perl (v5.8.4) was built without the requisite defines, and so the struct msghdr visible within my XS file is the older, BSD kind::

#include "EXTERN.h"
#include "perl.h"      /* older, "msg_accrights"-style msghdr now visible */
#include "XSUB.h"

....
  struct msghdr m;
  m.msg_control = buf;  /* ERROR, structure has no member named "msg_control" */
....

Supplying the "right" #defines (_XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED) breaks the build, since it changes a great many things that perl was expecting.

Is there an elegant way I can have the XS module use the structure definition I'd like?

+2  A: 

You either have to use the definitions that your existing perl understands, or compile a new perl with the definitions that you want.

You don't need to replace the existing perl, though. You can install the new perl separately so they don't conflict.

If you want it both ways, you have to figure out which definitions your Perl has and write code that handles the right set of definitions. You might add a layer of abstraction so you can implement the underlying bits with either set of definitions. It's a lot of repeated code probably, but that's what portability is, unfortunately. :(

brian d foy
+1 You've spurred me in another direction, however, and I think there'll be a distinct follow-up question.
pilcrow