Thread overview | |||||
---|---|---|---|---|---|
|
September 28, 2015 Tutorial on C++ Integration? | ||||
---|---|---|---|---|
| ||||
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 Re: Tutorial on C++ Integration? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike McKee | 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 Re: Tutorial on C++ Integration? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike McKee | 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 |
Copyright © 1999-2021 by the D Language Foundation