www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - BUG: wrong automatic conversion to char* string

reply KUV <KUV_member pathlink.com> writes:
I use this code to execute mysql query:

mysql_query(mySQL, "SELECT host_Id FROM hosts WHERE host_Id NOT IN (" ~
seenHosts ~ ")");

And sometimes get error in mysql syntax because of extra character (code 08) at
the end of line, according to mysql log.
I used to manual conversion by toStringz() function, and this worked ok:

char* z = toStringz("SELECT host_Id FROM hosts WHERE host_Id NOT IN (" ~
seenHosts ~ ")");
mysql_query(mySQL, z);

So I think this is caused by bug in the D compiler.
Jan 15 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

KUV schrieb am 2006-01-15:
 I use this code to execute mysql query:

 mysql_query(mySQL, "SELECT host_Id FROM hosts WHERE host_Id NOT IN (" ~
 seenHosts ~ ")");

 And sometimes get error in mysql syntax because of extra character (code 08) at
 the end of line, according to mysql log.
 I used to manual conversion by toStringz() function, and this worked ok:

 char* z = toStringz("SELECT host_Id FROM hosts WHERE host_Id NOT IN (" ~
 seenHosts ~ ")");
 mysql_query(mySQL, z);

 So I think this is caused by bug in the D compiler.

Only constant character arrays are zero terminated. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDzBJo3w+/yD4P9tIRAtoUAJ4/t6pz4bJbmlkxNJJlD85URGTGkgCg0Ax+ X8pQ/HC+B3KbEKngJteftKk= =0esM -----END PGP SIGNATURE-----
Jan 16 2006