extern(C++): Unresolved scalar deleting destructor

Stefan Koch uplink.coder at googlemail.com
Tue Jul 24 16:30:41 UTC 2018


On Tuesday, 24 July 2018 at 15:48:28 UTC, Vladimir Marchevsky 
wrote:
> After reading 2.081 patchnotes about improvements with binding 
> to cpp classes, I'm trying to test it - with simple examples 
> and Qt as cpp library.
>
> My naive approach is to bind just a couple of used methods of 
> specific classes (omitting others) and try to use it directly 
> in D just with linking of default Qt5Core.lib. Sometimes it 
> works just fine:
>
> ---app.d
> import std.conv;
> import std.stdio;
>
> extern(C++) {
>     class QVariant {
>         this();
>         this(int);
>         this(double);
>         final ~this();
>
>         final int toInt(bool *ok = null) const;
>         final double toDouble(bool *ok = null) const;
>     }
> }
>
> void main()
> {
>     QVariant a = new QVariant(5);
>     QVariant b = new QVariant(5.5);
>     writeln("a: " ~ a.toInt().to!string);
>     writeln("b: " ~ b.toDouble().to!string);
>     readln();
> }
> ---
>
> This example compiles and works like a charm.
>
> Other classes like QObject or QCoreApplication do not link with 
> error like this:
>
> cpptest.obj : error LNK2001: unresolved external symbol 
> ""public: virtual void * __cdecl QObject::`scalar deleting 
> destructor'(unsigned int)" (??_GQObject@@UEAAPEAXI at Z)"
>
> There is no such symbol in Qt5Core.lib, obviously. Is it my 
> mistake somewhere? Why do some classes require this destructor 
> when it doesnt actually exist in lib? And why do other classes 
> work without it?

Seems like it's virtual destructor could that be?

this qt5 binding: 
https://github.com/MGWL/QtE5/blob/master/source/qte5.d
seems to always define the constructor.



More information about the Digitalmars-d-learn mailing list