extern(C++): Unresolved scalar deleting destructor
Vladimir Marchevsky
vladimmi at gmail.com
Wed Jul 25 12:04:16 UTC 2018
Back to questions after homework done :) What I've tested:
Made test class in CPP:
---testlib.cpp
class __declspec(dllexport) Foo {
int *a;
public:
Foo(int value) {
a = new int(value);
}
~Foo() {
delete a;
}
};
---
Binding on D side:
---
extern(C++) {
class Foo {
this(int value);
final ~this(); //btw, is this a correct way to bind a
non-virtual member?
//What about inheritance and so on?..
}
}
---
Binding works perfect, both ctor and dtor work.
Changed dtor to be virtual (and removed final from D side) -
anyway, compiles and works perfect. I can provide D
implementation of destructor which replaces original virtual one
(is it correct? Or can I call original one from D-specified?) -
making it empty leads to memory leak as expected. So I see no
problems here.
Back to QObject. Its destructor is "virtual ~QObject();" but
having "~this();" on D side again leads to "unresolved scalar
deleting destructor" of QObject. It looks like actual destructor
binds correct (I would have another error if I make binding
incorrect with "final ~this()") but for some reason it wants this
another thing... Why?
More information about the Digitalmars-d-learn
mailing list