[fpc-devel] Linking to C++

Den Jean Den.Jean at telenet.be
Mon Jan 22 22:02:38 CET 2007

On Monday 22 January 2007 20:17, Felipe Monteiro de Carvalho wrote:
> Hello,
> Now, I utilized dllview software I created and saw that cpplib exports
> this function: _ZN4User3SumEii
IIRC C++ compiler/platform dependant.
So do not use this to be compiler independant
GCC even changed its name mangling in between versions.

> Then, I created a simple pascal software to call that function:
> program loadcpp;
> {$mode objfpc}{$H+}
> One possible problem is C++ multiple inheritance. I would propose
> that, to start with, just disconsider it.
AFAIK the class that inherits from multiple classes, is actually
just several classes with several vtables. To be able to
use it from pascal, the self pointer in
    function User_Sum(Self: Pointer; a, b: cint): cint; cdecl; external
should be different depending on which vtable you want to call.


implementation of QWidget_to_QPaintDevice:
	QPaintDeviceH QWidget_to_QPaintDevice(QWidgetH handle)
		return (QPaintDeviceH)(QPaintDevice *)(QWidget *)handle;

the typecast (QPaintDevice *) turns the number (QWidget *)handle into another 
number, pointing to another vtable. 

But again this is compiler/version dependant reading the following:


Den Jean

More information about the fpc-devel mailing list