tomw1975 has asked for the wisdom of the Perl Monks concerning the following question:

Since I have upgraded to 5.8 my C perl interface won't work. I noticed that in the small print of the release it says that it is not backward compatible!?!? and the XS functions wont work. My question is how do I get my code to run??

here is the code

#include <EXTERN.h> #include <perl.h> #include <stdio.h> #include <stdlib.h> #include "GIEAsnmp.h" #define CLIENT_ID "INTERFACE" static PerlInterpreter *my_perl; int count; int counter; char *queue; char *tempPop; char *temp; int i = 0; EXTERN_C void xs_init _((void)); EXTERN_C void boot_DynaLoader _((CV* cv)); EXTERN_C void xs_init(void) { char *file = __FILE__; dXSUB_SYS; /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); } struct interpreter * perlstart() { char *my_argv[] = { "", "dataquery.pl"}; my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, xs_init, 2, my_argv, (char **)NULL); return (my_perl); } void perlstop(struct interpreter *my_perl) { perl_destruct (my_perl); perl_free(my_perl); }

there is more but I think that should illustrate the issue. I have tried removing all the xs related stuff but constantly get the errors below when trying to compile

"struct drand48 data" is undefinded as well as "struct random_data" is undefined from reentr.h, this is all on an AIX box by the way - I wasn't even aware I was using the two structures!!!

Any help would be greatly appreciated!
Incidently the errors I am getting from my XS stuff are from the newXS line and the perl_parse line and the erros were:

"interface.c", line 32.46: 1506-280 (W) Function argument assignment b +etween types "void(*)(struct interpreter*,struct cv*)" and "void(*)(struct cv*)" is not allowed. "interface.c", line 49.21: 1506-280 (W) Function argument assignment b +etween types "void(*)(struct interpreter*)" and "void(*)(v oid)" is not allowed.

sorry for the long post!

Replies are listed 'Best First'.
Re: 5.8 upgrade causing embeding issues!
by PodMaster (Abbot) on May 26, 2004 at 03:28 UTC
    `perldoc ExtUtils::Embed'

    Now, running perl -MExtUtils::Embed -e xsinit on my old 5.6.1 perl gives

    #include <EXTERN.h> #include <perl.h> EXTERN_C void xs_init (pTHXo); EXTERN_C void boot_DynaLoader (pTHXo_ CV* cv); EXTERN_C void xs_init(pTHXo) { char *file = __FILE__; dXSUB_SYS; /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); }
    I don't know if it will matter much (no c expert, dunno much about aix), but I'd try that using that instead of that xs_init(void) stuff. Also, your tiny error snippet is too tiny. You need to show how the compiler was invoked and all the messages it printed out (hopefully you're using ExtUtils::Embed for the compiler options).

    update: Corion: s!EstUtils!ExtUtils!g

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: 5.8 upgrade causing embeding issues!
by tomw1975 (Sexton) on May 26, 2004 at 13:57 UTC
    Ok I added the xs_init (pTHX) and that seems to have cleared up the issues with the xs errors. However the errors I am getting from the reentr.h header are still causing an issue.
    "/usr/opt/perl5/lib/5.8.0/aix-thread-multi/CORE/reentr.h", line 610.16 +: 1506-007 (S) "struct drand48_data" is undefined. "/usr/opt/perl5/lib/5.8.0/aix-thread-multi/CORE/reentr.h", line 717.16 +: 1506-007 (S) "struct random_data" is undefined.

    I have tried compiling this several ways including the way suggested in perlembed.pod

    cc -o interface interface.c `perl -MExtUtils::Embed -e ccopts -e ldopt +s`

    Any other people had this particular issue when upgrading to 5.8???

    Thanks