A question about C++ interop
YD
diyu60607 at yahoo.com
Sun Mar 29 15:20:52 UTC 2020
On Sunday, 29 March 2020 at 01:50:24 UTC, evilrat wrote:
> ...
>
> Same here, STL bindings is not yet finished. If you don't need
> that method specifically, just replace it with a dummy. Or make
> your own bindings.
Thanks, dummy placeholder works. But there is a new problem on
Windows, let's say there are two classes in C++:
class Y {
...
};
class X {
public:
void call(Y const * y) const;
};
on Windows, the library file (compiled with Visual C++) contains
an entry like this:
16C 00000020 SECT4 notype () External |
?call at X@@QBEXPBVY@@@Z (public: void __thiscall X::call(class Y
const *)const )
Then I declare it in D like this:
extern(C++) {
class Y {
...
}
class X {
final void call(const(Y) y) const;
}
}
The object file for this D code (compiled with ldc2) will contain
an entry like this:
0A7 00000000 UNDEF notype External |
?call at X@@QBEXQBVY@@@Z (public: void __thiscall X::call(class Y
const * const)const )
So there is a subtle difference in the signature, and the linker
refuses to resolve the symbol.
I tried "const Y y", "const(Y*) y", and "ref const(Y) y", but
none of them manages to match the library file entry.
(This problem somehow does not appear on Linux where the library
file is compiled with gcc, though)
So what do I need to declare in the D file for it to match the
library entry? Thanks!
More information about the Digitalmars-d-learn
mailing list