Re: perl gtk2

On Thu, Oct 10, 2002 at 03:09:46PM +0200, Guillaume Cottenceau wrote:
goran kirra net writes:

when installed Inline-based modules does not need a C compiler.

During development it does need it of course but so does any
method to bind C-libraries to perl.

Sorry, I just tested quickly (we don't have it in the
mandrake distro) with a perl -e, so I missed that point. It uses
a caching system?

I generates XS which is compiled to shared objects.

So it seems that XS and Inline are quite close to each other
then. I'd personally still favor XS for the indenting and syntax
highlighting of C code, but that's not a big difference for sure.

You can place the C-code of inline in *.c files with *.pm as
a bootstrap to quote Ingy:
---- snip ---------------------------------------------------

2) Divide into two files:

---8<--- (
package Math::Simple;
use strict;
require Exporter;
@Math::Simple::ISA = qw(Exporter);
@Math::Simple::EXPORT = qw(add subtract);
$Math::Simple::VERSION = '1.23';

use Inline (C => 'src/Simple.c' =>
            NAME => 'Math::Simple::Stuff',
            VERSION => '1.23',
---8<--- (src/Simple.c)
int add (int x, int y) {
    return x + y;

int subtract (int x, int y) {
    return x - y;

So now you have the Perl in one file and the C in the other. The C code
must be in a subdirectory.
---- snip ---------------------------------------------------

That way you get pure C code in the *.c files and still avoids the querky syntax
of XS.
Perhaps I will try this kind of split in my next snapshot.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]