Interfacing with C++ Class named Object
Timoses
timosesu at gmail.com
Tue May 1 16:07:30 UTC 2018
On Tuesday, 1 May 2018 at 15:24:09 UTC, Robert M. Münch wrote:
> Hi, I'm mostly doing simple C-API wrappers around C++ code to
> access thigns from D. However, I wanted to try how far I can
> come using C++ directly.
>
> I have the following C++ code in namespace N:
>
> class Image : public Object {
> Error create(int w, int h, uint32_t p) noexcept;
> }
> And I have the following D code:
> extern (C++, N) {
> class Object {
> }
> class Image : public Object {
> uint create(int w, int h, uint pixelFormat);
> }
> }
> So frist problem I see is, that a C++ class names Object is
> pretty unfortunate as this is a reserved class name in D. And
> DMD doesn't seem to allow using Object inside a C++ scope
> (which IMO should be possible).
> Am I right, that there is no chance to handle this case other
> than ranming the C++ base class?
Would `pragma(mangle, ...)` work here?
https://dlang.org/spec/pragma.html#mangle
More information about the Digitalmars-d-learn
mailing list