[fpc-pascal] Re: Automatically exporting C++ API using SWIG??

Michael Van Canneyt michael at freepascal.org
Thu Aug 1 11:37:26 CEST 2013



On Thu, 1 Aug 2013, dev.dliw at gmail.com wrote:

> Hi,
>> FYI, created wiki page http://wiki.lazarus.freepascal.org/SWIG to bundle
>> information.
>
>> It would of course be very welcome if somebody got the current version into
>> main SWIG so it is more easily usable
>
> The wiki page is a good idea, things have to be clarified though.
>
> I don't know in how far others dealt with the code in the meantime - so this
> is my personal view:
>
> When I ported the patch to 2.0.8 things looked quite good, the changes needed
> were very straightforward - and in the end the result was quite usable.
>
> But IMO the code itself is / was a big mess and far from being clean &
> readable - which is no bigger problem if 'it simply works' :D
>
> Now - I tried a port to latest swig (2.0.10) some months ago [even made a fork
> on github...], but never released, the reason: it doesn't work any more.
> I didn't search for the relevant changes in their changelog, but I didn't
> managed to get it even compiled - too many functions simply were missing.
>
> Even worse, the Fortran module (upon which the Delphi module is based)
> although being in trunk also didn't compile - exactly the same missing
> functions.
>
> In short: IMHO the patch is too much bitrotten to be further used, I think a
> clean and new implementation from scratch would be the much better way.
>
> Maybe this can do the trick, too:
> https://github.com/swig/swig/wiki/GSoC-2013-ideas#wiki-Support_for_C_as_target_language
> I mean, h2pas does a decent job...
>
> And if it's allowed to dream: one time fpc will simply link against C++
> directly :)

Not even C++ compilers can use each other's DLLs, if I understood correctly.

I just received a (clean) patch from Sven Barth, which expands on your patch.
It's on 2.0.8, and indeed does not work with swig trunk.

I was planning to try and get this into swig, but after your remarks, 
I am no longer so sure that this is a good idea :)

Michael.



More information about the fpc-pascal mailing list