Question

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?

Was it helpful?

Solution

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. :(

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top