Problems with string literals and etc.c.odbc.sql functions

Marc Sch├╝tz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 19 05:20:03 PST 2015


On Friday, 18 December 2015 at 22:35:04 UTC, anonymous wrote:
> If the parameter is really not const, i.e. the function may 
> mutate the argument, then the cast is not ok. You can use 
> `.dup.ptr` instead to get a proper char* from a string.

As this is going to be passed to a C function, it would need to 
be zero-terminated. `.dup` doesn't do this, he'd have to use 
`std.string.toStringz` instead. However, that function returns a 
`immutable(char)*`, which would have to be cast again :-(


More information about the Digitalmars-d-learn mailing list