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

Sven Barth pascaldragon at googlemail.com
Thu Aug 1 13:11:59 CEST 2013

Am 01.08.2013 12:47, schrieb Reinier Olislagers:
> On 01/08/2013 12:24, Sven Barth wrote:
>> Am 01.08.2013 12:11, schrieb Michael Van Canneyt:
>>> On Thu, 1 Aug 2013, Sven Barth wrote:
>>>> Am 01.08.2013 11:38, schrieb Michael Van Canneyt:
>>>>> On Thu, 1 Aug 2013, Sven Barth wrote:
>>>>>> Am 01.08.2013 11:10, schrieb
>>>>> How do you handle different binary formats of C++ compilers ?
>>>>> Or is this meanwhile standardized ?
>>>> Support for every C++ compiler (mainly MSVC, C++ builder and GCC
>>>> [LLVM counts here as GCC]) needs to be implemented explicitely,
> <snip>
>>> Since a library is provided by a vendor, I'd say you normally
>>> interface with one compiler per lib that you target, no ?
>> That's basically what I said :)
>>>> As a first step I'd only target GCC and LLVM as these are the main
>>>> compilers for the majority of our platforms.
>>> Eh, MSVC also seems popular on windows ? ;)
>> We have three windows platforms with MSVC and I don't know how many
>> platforms where GCC or LLVM is the main compiler. I'm not going for
>> popularity here, just for the majority of platforms.
> Looking at the options
> 1 use swig architecture to parse the C++ source code/headers and extract
> Pascal bindings - either by a rewrite or adapting the current effort
> 2 accommodate (and maintain) various compiler idiosyncracies
> from a distance... I'd say option 1 would be the easiest and best
> maintainable?
> - SWIG already provides infrastructure to parse the source files
> - People using Delphi would probably also be interested in
> fixing/patching bugs
> - On top of the previous point: changes in C/C++ standards/formats would
> not be our concern so much because those will be dealt with by the wider
> SWIG community
> - Of course, if swig is ever extended to support more languages, we get
> that for free
> Of course I understand it's very attractive to have everything in house
> and native in FPC, but I suspect the effort needed to develop/maintain
> it may outweigh that...
Important point for variant 2: less overhead. Using swig you first 
flatten the API and then unflatten it again into Object Pascal classes. 
For callbacks you have also wrappers (which are hidden from you). In 
case of cppclass you don't have all this, because code will be called 


More information about the fpc-pascal mailing list