Interfacing with C++ Class named Object

Robert M. Münch robert.muench at
Tue May 1 15:24:09 UTC 2018

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++ 

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?

Robert M. Münch
smarter | better | faster

More information about the Digitalmars-d-learn mailing list