returning D string from C++?

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 6 16:53:46 PDT 2017


On Sunday, 6 August 2017 at 17:16:05 UTC, bitwise wrote:

>
> I was referring specifically to storing gc_malloc'ed pointers 
> on the stack, meaning that I'm calling a C++ function on a D 
> call stack, and storing the pointer as a local var in the C++ 
> function before returning it to D.
>
> The more I think about it, the more I think it has to be ok to 
> do. Unless D stores [ESP] to some variable at each extern(*) 
> function call, then the GC would have no choice but 
> indifference as to what side of the language boundary it was 
> scanning on. If it did, I imagine it would say so here:
>
> https://dlang.org/spec/cpp_interface.html#memory-allocation

Yes, as long as you can guarantee it stays on the stack you 
should be good to go.


More information about the Digitalmars-d-learn mailing list