David Cannings | 4 May 2004 19:18

Is SWIG appropriate

I am no great programmer in either C or Perl but am trying to convert a C 
header file into a Perl module.  I have one that was made by somebody 
else using an old version of h2xs and old versions of the header files 
but now want to update it and document it properly.  The header files are 
from the MTA Exim and I want to be able to call certain functions from 
the C file from Perl.

I have tried using h2xs to convert the header file without success so have 
given up trying to use it.  Its behaviour isn't consistent with the 
manual page and there are bugs in perlbug that are three years old 
relating to my problems.  I get no response from Perl mailing lists 
either, because of this I found SWIG.  

The defines a number of functions, an enum and some other variables such 
as "extern uschar *message_id".  I decided to start small and get one 
method working so have created myself a file called LocalScan.i that 
contains:

-- File: LocalScan.i --
%module LocalScan
 %{
 /* Includes the header in the wrapper code */
 #include "local_scan.h"
 %}

 /* Parse the header file to generate wrappers */

extern void    header_add(int, char *, ...);
-- End file --

(Continue reading)

John Lenz | 4 May 2004 20:18
Picon

Re: Is SWIG appropriate

On 2004.05.04 12:18, David Cannings wrote:

> # gcc -c LocalScan_wrap.c local_scan.c -I/usr/lib/perl/5.8/CORE
> -I../exim4-4.31/src

Sigh.
http://www.swig.org/Doc1.3/Perl5.html#n9

Read the part that starts with "If you see errors having to do with  
_crypt_struct, ..."

perl -e 'use Config; print $Config{ccflags};'

John
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Cannings | 4 May 2004 20:27

Re: Is SWIG appropriate

On Tuesday 04 May 2004 19:18, John Lenz wrote:
> On 2004.05.04 12:18, David Cannings wrote:
> > # gcc -c LocalScan_wrap.c local_scan.c -I/usr/lib/perl/5.8/CORE
> > -I../exim4-4.31/src
>
> Sigh.
> http://www.swig.org/Doc1.3/Perl5.html#n9
>
> Read the part that starts with "If you see errors having to do with
> _crypt_struct, ..."
>
> perl -e 'use Config; print $Config{ccflags};'

My apologies, I hadn't seen the FAQ.  This fixes the problem and I now 
have a .o file.

Thank you,

David
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig


Gmane