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

Sven Barth pascaldragon at googlemail.com
Thu Aug 1 12:05:47 CEST 2013


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 dev.dliw at gmail.com:
>>> And if it's allowed to dream: one time fpc will simply link against C++
>>> directly :)
>> If you prefer to work in Pascal instead of C++ then you could work on 
>> that dream by improving the cppclass code in the compiler. Linking 
>> against static C++ class methods already works, what's (basically) 
>> missing is support for C++ runtimes (at first the stdc++ one would be 
>> sufficient), support for vtables and object instantiation/destruction.
>
> 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, because they 
not only differ in class layout, but also in e.g. name mangling. So in 
the end (if we want to support more than GCC and LLVM) we'll need to use 
a directive to declare which compiler to target and this then includes a 
corresponding interface unit for the runtime (like is done with 
Objective C) and let the compiler generate the code correctly. Maybe 
together with packages support it should be possible to interface with 
multiple different compilers at once.

As a first step I'd only target GCC and LLVM as these are the main 
compilers for the majority of our platforms.

Regards,
Sven



More information about the fpc-pascal mailing list