Hello again,
I have have problems embedding perl subroutines. According to
documentation it is possible to call a Perl sub from a XSUB.

Below is an example from a perl sub that is to be called and
the c routine that call the perl sub.

All code is taken from examples but running this ends up with a
"Debug Error: ESP was not properly saved cross function calls..."

Is there anyone who knows the calling convention that is to be used?

Thanks in advance
Regards
Bo Holmstedt

################    CODE example    ##################

sub test_sub {
        $ptr = @_;
        print "test_sub called ...\n";
}

void
call_back(char *function,void *ptr)
{
        int rc=0;

        dSP;
        ENTER;    /* New scope  */
        SAVETMPS; /* FREETMPS will free all mortals*/
                  /* created after this point   */
        PUSHMARK(SP); /* Remember current stack pointer */
        
        XPUSHs(sv_2mortal(newSViv((IV)ptr)));

        PUTBACK; /* End of arguments    */
        rc = call_pv(function,G_DISCARD);
        
        if ( rc != 0 ){
                printf("Something is corrupt !!!\n");
        }
        
        SPAGAIN;  /* Start looking at return values      */ 
        PUTBACK;  /* Finshed removing results from stack */
        FREETMPS; /* Frees the mortal arguments          */
        LEAVE;    /* Leave the scope                     */
}

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to