std.conv.to!string refuses to convert a char* to string.
Mike Parker
aldacron at gmail.com
Sat Dec 9 08:29:04 UTC 2017
On Saturday, 9 December 2017 at 06:14:36 UTC, Venkat wrote:
> Thanks for the quick response. std.string.fromStringz did the
> trick. I am not sure what was the deal with to!string.
Be careful with fromStringz. It doesn't allocate a new string, so
the returned string can easily become corrupted if the C string
it's referencing falls off the stack.
As for your problem with to!string, it isn't actually to!string
that's the issue. It appears to have something to do with the
memory allocated from the GC. I assume this is a shared library.
Random thoughts -- Have you initialized DRuntime? Have you
registered the calling thread with the GC?
More information about the Digitalmars-d-learn
mailing list