Thread overview
Tutorial on C++ Integration?
Sep 28, 2015
Mike McKee
Sep 28, 2015
Kagamin
Sep 28, 2015
Jacob Carlborg
September 28, 2015
I'm using Qt/C++ on a Mac. I want to try my hand at making a dylib in D that can receive a C++ string, reverse it, and respond with the result back to Qt/C++.

Are there any easy tutorials out there with something simple like that?

You probably want me to type some code so that I showed that I at least tried something. Okay, here's me just guessing:

// test.dylib

auto _cstr2dstr(inout(char)* cstr) {
    import core.stdc.string: strlen;
    return cstr ? cstr[0 .. strlen(cstr)] : cstr[0 .. 0];
}

extern(C++) char*  reverseString(char* cstr) {
  import std.string;
  import std.algorithm;
  s = _cstr2dstr(cstr);
  s = s.reverse();
  return toStringz(s);
}

Also, what do I type to define this as a class that C++ can call, such as the following C++?

QObject Foo = new Foo();
qDebug() << Foo.reverseString('bar');

Next, I'm a bit fuzzy on how to compile that into a dylib yet, as well as how to call this inside of Qt/C++ with QtCreator.
September 28, 2015
http://wiki.dlang.org/Vision/2015H1 C++ integration was planned to be available by the end of 2015. May be too optimistic still.
September 28, 2015
On 2015-09-28 09:08, Mike McKee wrote:
> I'm using Qt/C++ on a Mac. I want to try my hand at making a dylib in D

Dynamic libraries are not officially supported on OS X.

-- 
/Jacob Carlborg