Sorry, hopefully better late than never.

On 10/02/03 18:16 +0100, Janek Schleicher wrote:
> On Mon, 10 Feb 2003 09:57:48 -0800, Clint Olsen wrote:
> 
> Thanks for your quick answer.
> 
> >> What is Better Practice?
> >> 
> >> PS: I'm really sorry, if this is a simple question. But I'm more a Perl
> >> programmer who only wants to use some existing c code from Perl. And
> >> however, I miss an example for this problem, e.g. via perldoc
> >> Inline::C-Cookbook

Well the easiest way is to just pass the name of the C file to Inline
directly:

    use Inline C => '/home/ingy/foo.c';


> > The problem is Inline's inability to use code from outside libraries and
> > just use their header file(s) as an interface cue.  This is one place where
> > SWIG really shines.  People don't necessarily want to glob all their C in
> > one file for Inline to use.  That's why we write libraries.

Inline binds to libraries just fine. As you say, it does not generate an
interface from a header file, but I'm just not convinced that's a good
idea. I've always said that good C interfaces do not make good Perl
interfaces. I'm open to discussion with some actual use case examples
though.

And BTW, I've always discouraged dumping a ton of C code into your Perl.
Create a library, definitely. And write only your interface code inline.

FWIW, I'm actually using Inline *right now* to bind to a third party C
library. I definitely know I wouldn't want to see the entire header file
exposed to Perl. What a mess. I just need a couple interface functions,
and it's worth my time to hand tune them.

I am running into some problems though. Like line numbers. It would be
really handy if they matched my Perl module source file. 

This will probably result in a minor release fairly soon :)

Cheers, Brian


> Stupid question again.
> 
> What's the big problem for Inline to handle it ?
> I can't imagine that it is so difficult to handle with extern c files, as
> every c compiler can, isn't it ?
> In my imagination, that can't be that difficult and unable to solve.
> 
> A second question is still,
> what's the good practice to workaround Inline's inability.
> Just write the c library?
> 
> Greetings,
> Janek
> 
> PS: Of course, I so or so will find another way. At least I'll connect the
> original author to write or accept a library, what is on the long term the
> right way in any way. But still, I find my question interesting. I
> normally would all the routines called directly from Perl inlined and the
> rest outsourced to one or several c files, wouldn't you!?
> As I'm really interested in, I would also be ready to help with
> development, allthough I'm afraid that my c knowledge ain't good enough.

Reply via email to