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

Michael Van Canneyt michael at freepascal.org
Thu Aug 1 12:11:21 CEST 2013



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 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.

Since a library is provided by a vendor, I'd say you normally interface with one compiler per lib that you target, no ?

>
> 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 ? ;)

Michael.



More information about the fpc-pascal mailing list