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

Fer22f via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 18 16:06:38 PST 2015


On Friday, 18 December 2015 at 22:35:04 UTC, anonymous wrote:
> If the parameter is de facto const, then the cast is ok. 
> Though, maybe it should be marked const then.

I'm just worried about casts because I read somewhere that 
strings start with the number of characters inside them (probably 
in slices documentation), and not with actual content (though 
string literals probably act different in this case).

Documentation on casts say:

Casting a pointer type to and from a class type is done as a type 
paint (i.e. a reinterpret cast).

Reinterpretation is rather dangerous if strings are stored 
differently.

But this test gives me a good hope on this case:

     writeln(*(cast(char*) "Test"));

Casting is what I'm going with. .dup.ptr is less clear in this 
case.


More information about the Digitalmars-d-learn mailing list