[fpc-devel] Linking to C++
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Mon Jan 22 21:45:03 CET 2007
> I don't know what FPC does with member functions, but Delphi does not
export them. You cannot put a member function in the export part of a
library. You have to create a wrapper (normal function with Self as the
first argument) and then export the wrapper. So, if you happen to have a
good class API in Delphi, you have to manually type wrappers and export
them. This can be changed in FPC by allowing TMyObject.MyFunction in the
export part of a library.
That would be nice!
But would would be the inverse of exporting a method?
Maybe this:
type
User = class
public:
function Sum(a, b: Integer): Integer; external 'mylib.dll';
end;
being that Sum is a method created on a object pascal library.
On 1/22/07, Daniël Mantione <daniel.mantione at freepascal.org> wrote:
> Of course, you can import a class like you did, and even automate it, I
> don't see a problem with adding C++ mangling. But, you cannot use class
> syntax, since classes are fundamentally incompatible with C++ classes.
Automating C++ mangling would already be great, but if one can´t use
c++ methods inside classes, how will the name mangler know that the
function is actually a method from a class with a given name?
And how would this be added? Extra keywords to be added to functions?
Maybe 2 different keywords, one for cpp method name mangling and
another for c function name mangling, so I would declare:
function User.Sum(Self: Pointer; a, b: cint): cint; cdecl; external
'cpplib.dll'; cpp_method_name_mandling;
On this solution we treat the C++ object as a pointer that is passed
around, and can only be created and destroyed by imported functions.
--
Felipe Monteiro de Carvalho
More information about the fpc-devel
mailing list