Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

(Ovid) Re: Inline::C code doesn't work, but the C code does

by Ovid (Cardinal)
on Dec 28, 2001 at 23:39 UTC ( [id://134946]=note: print w/replies, xml ) Need Help??


in reply to Inline::C code doesn't work, but the C code does

I saw your question on the mailing list and it was bugging me that no one bothered to answer it. Of course, since I've joined the mailing list, your's is the only post that I've seen :(

On the mailing list code, you're not having a problem. With this code, you've calling a sub you haven't declared :) - my_create_context versus create_context. Of course, since it's obvious you're still massaging it, this is not the problem. From what you are saying, the problem lies here:

/* This is the call that is failing */ status = ivadmin_context_createdefault(user,passwd,&ctx,&rsp);

How do you know this is where the error is? You don't supply us with any error message. Also, and I know this sounds too elementary, have you printed all of the values before and after the "createdefault" call?

(Entering deep waters here) I'm also wondering about the typedefs for ivadmin_context and ivadmin_response. Do you need to specify new typemaps for them? I thought this was only an issue when declaring return types, but I could be wrong. Do you have anyway of verifying that Perl is handling these correctly?

Cheers,
Ovid

Update: You mentioned on the mailing list that you're using the same compiler as when you compiled Perl. Are you using the same 'make' utility? An article at http://www.perl.com/ by the Inline author suggests that this will cause problems (though he does not elaborate).

I'd also try the following one-liner:

perl -MInline=Info,force,NoClean yourcode.pl

That forces Information about bound subs to be printed to STDERR. It also forces a recompile and leaves the build directories intact so you can browse through them for more information.

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: Inline::C code doesn't work, but the C code does
by mikfire (Deacon) on Dec 29, 2001 at 00:35 UTC
    I know the call to ivadmin_context_createdefault() isn't working because ivadmin_response_getok is saying so. And, since the identical code works as a C program, I know it isn't my call to the library.

    The PREFIX option on the use Inline C line causes perl to "strip" that prefix from the function as defined in the C code. Thus, I define it as my_create_context in the C code, and use it as create_context in the perl code.

    Upon reading the docs a bit closer, if Inline didn't like the return type from my_context_create, it would simply ignore the function. As I can call it from perl, I assume this isn't the problem. Again, if I read the docs right, I don't need a typemap unless I intend on using one of those structs as a return type.

    I tried your suggestion on the update, and it is saying the function has been bound to perl. I have also browsed the generated XS code and it looks correct to me, although I think I indicated previously that my XS skills are nonexistent.

    I am using the same make.

    Thanks for the suggestions, Ovid. I am back to hitting the docs and trying ( once again ) to work my way through perlapi.

    mikfire

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://134946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2025-07-11 12:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.