develooper Front page | perl.perl5.porters | Postings from October 2001

RE: [PATCH h2xs] Use of static data in XS modules

Thread Previous | Thread Next
Paul Marquess
October 29, 2001 04:01
RE: [PATCH h2xs] Use of static data in XS modules
Message ID:
From: Gurusamy Sarathy []

> On Sun, 28 Oct 2001 22:02:52 GMT, Tim Bunce wrote:
> >I think it needs some more words of explanation (or pointers) in
> >the docs and/or generated code as to why it's needed and how the fields
> >in the struct are accessed.
> Yes, ideally, there would be documentation and examples in perlxs.pod.
> Paul said he might look into that.  Right now, perl.h has the following
> by way of comments, which should be enough for someone to write the
> perlxs.pod additions:

Yep, I was intending to add a few words to perlxs.pod at the weekend, but
life got in the way. I have a few sentences cobbled together, but I need to
find some the time to add a few more.

The next change I need to make for h2xs is to add a chunk of
"backward-compatibility" code to allow older Perl's to make use of this
facility. I'm tempted just to get h2xs to spit out an extra file called,
say, "compat.h".

It would just contain all the CXT* code from perl.h modified to work older
Perl's, and the whole thing surrounded by a #if perl < 5.8

Then the .xs file just gets this:

    #include "EXTERN.h"
    #include "perl.h"
    #include "XSUB.h"
    #include "compat.h"

I think this is cleaner than dumping all the CXT* code straight into the .xs

The "compat.h" file could then be used as the place for h2xs to put other
backward compatibility code in the future.

Here's a candidate for inclusion that I have in all of my modules.

#    include "patchlevel.h"
#    define PERL_REVISION	5

Another possibility is mapping of pre-PL_* names to the PL_* equivalent

#if PERL_REVISION == 5 && (PERL_VERSION < 4 || \
    (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 ))

#    define PL_sv_undef		sv_undef
#    define PL_na		na



Do You Yahoo!?
Get your free address at

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About