digitalmars.D.learn - dmd 178 changes
- Ant (23/23) Dec 10 2006 ok, I jump a few releases and missed a lot of discussions...
- Ant (7/7) Dec 10 2006 and more, this is invalid:
- Unknown W. Brackets (2/15) Dec 10 2006
- Lionello Lunesu (6/19) Dec 11 2006 Well, I think it actually IS invalid. The string in your first example
- %u (3/3) Dec 11 2006 You're right, and it all makes sense.
- Thomas Kuehne (24/39) Dec 10 2006 -----BEGIN PGP SIGNED MESSAGE-----
ok, I jump a few releases and missed a lot of discussions...
this isn't valid anymore:
/**
* get the C version of command line in the format char**
*/
static char** getCommandLine(char[][] args)
{
// Walter version from a post on the D news group
char** argv = new char*[args.length];
int i = 0;
foreach (char[] p; args)
{
argv[i++] = cast(char*)p;
}
return argv;
}
how to we do the
char** argv = new char*[args.length];
?
like:
&((new char*[args.length])[0]);
?
Ant
Dec 10 2006
and more, this is invalid:
printf("Couldn't compile sources for "~name.toString()~"\n");
function object.printf (char*,...) does not match parameter types (char[])
but this is valid:
printf("Couldn't compile sources for ");//~name.toString()~"\n");
???
Ant
Dec 10 2006
Use toStringz() or writefln().
-[Unknown]
and more, this is invalid:
printf("Couldn't compile sources for "~name.toString()~"\n");
function object.printf (char*,...) does not match parameter types (char[])
but this is valid:
printf("Couldn't compile sources for ");//~name.toString()~"\n");
???
Ant
Dec 10 2006
Ant wrote:
and more, this is invalid:
printf("Couldn't compile sources for "~name.toString()~"\n");
function object.printf (char*,...) does not match parameter types (char[])
but this is valid:
printf("Couldn't compile sources for ");//~name.toString()~"\n");
???
Ant
Well, I think it actually IS invalid. The string in your first example
is not zero terminated! A string literal guaranteed to be zero
terminated, but a char[] is not. This is a perfect example why [] -> *
conversion was removed.
L.
Dec 11 2006
You're right, and it all makes sense. Thank you, TK, Unknown and L. Ant
Dec 11 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ant schrieb am 2006-12-11:
ok, I jump a few releases and missed a lot of discussions...
this isn't valid anymore:
/**
* get the C version of command line in the format char**
*/
static char** getCommandLine(char[][] args)
{
// Walter version from a post on the D news group
char** argv = new char*[args.length];
int i = 0;
foreach (char[] p; args)
{
argv[i++] = cast(char*)p;
}
return argv;
DMD-0.177: Arrays no longer implicitly convert to pointers unless -d is used.
/**
* get the C version of command line in the format char**
*/
static char** getCommandLine(char[][] args)
{
// Walter version from a post on the D news group
char** argv = (new char*[args.length]).ptr;
int i = 0;
foreach (char[] p; args)
{
argv[i++] = p.ptr;
}
return argv;
}
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFfQTbLK5blCcjpWoRAuFpAJ9Y9DYi9fMGx1xKKxzao+HwUeiQjQCfZL6H
pZj5wV/AHDVFBwniikYlBuI=
=LAOW
-----END PGP SIGNATURE-----
Dec 10 2006









"Unknown W. Brackets" <unknown simplemachines.org> 