Re: Using FFI to write a std::string to a buffer passed in from D

2024-07-21 Thread Troy via Digitalmars-d-learn
On Sunday, 21 July 2024 at 15:31:47 UTC, Johan wrote: On Sunday, 21 July 2024 at 13:35:46 UTC, Troy wrote: void create(void* b) { std::string s = "engineer again"; *(std::string*)(b) = s;// Segfault here } You have to construct an empty string object first in location `b` (em

Using FFI to write a std::string to a buffer passed in from D

2024-07-21 Thread Troy via Digitalmars-d-learn
I have a weird issue I've been running into while trying to write D bindings to some C++ code. I'm trying to call some C++ functions that take in a std::string but don't make a copy of it. To do this, I want to write a std::string to a buffer passed in from D so I can keep it from being destr