Thread overview
dmd 178 changes
Dec 11, 2006
Ant
Re: dmd 178 changes (177 not 178) and more
Dec 11, 2006
Ant
Dec 11, 2006
Lionello Lunesu
Dec 11, 2006
%u
Dec 11, 2006
Thomas Kuehne
December 11, 2006
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
December 11, 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
December 11, 2006
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

December 11, 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
December 11, 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.
December 11, 2006
You're right, and it all makes sense.

Thank you, TK, Unknown and L.

Ant