_argptr behaves different on cross compiler

Matt Brandt justmattb at walkingdog.net
Wed Feb 28 16:47:15 PST 2007


The following snippet of code illustrates the problem. It compiles fine on my macbook pro (gdc 0.22 with gcc 4.0.1), but gets the following message on x86 linux cross compiling to powerpc:

rpcclient.d:185: Error: cannot change reference to static array '_argptr'
rpcclient.d:185: Error: '_argptr' is not a scalar, it is a ubyte[12][1]
rpcclient.d:185: Error: incompatible types for ((_argptr) += (4)): 'ubyte[12][1]' and 'uint'
rpcclient.d:185: Error: '_argptr' is not an arithmetic type
rpcclient.d:192: Error: cannot change reference to static array '_argptr'
rpcclient.d:192: Error: '_argptr' is not a scalar, it is a ubyte[12][1]
rpcclient.d:192: Error: incompatible types for ((_argptr) += (8)): 'ubyte[12][1]' and 'uint'
rpcclient.d:192: Error: '_argptr' is not an arithmetic type

here is the code...

	synchronized char[]	callrpc(char[] fcn, ...)
	{
		++seq;
		char[]	call = format(" %s ", fcn);
		
		for( int i = 0; i < _arguments.length; ++i )
		{
			if( _arguments[i] == typeid(int) )
			{
				int		arg = *cast(int*)_argptr;
				
				call ~= format("%d ", arg);
				_argptr += int.sizeof;               // line 185
			}
			else if( _arguments[i] == typeid(char[]) )
			{
				char[]	arg = *cast(char[]*)_argptr;
				
				call ~= format("%s ", quote(arg));
				_argptr += (char[]).sizeof;       // line 192
			}
			else
			{
				writefln("unknown argument type: %s", _arguments[i]);
				break;
			}
		}

This is pretty much straight out of the online doc, so it seems like it should work. It actually does do the correct thing on the mac...

Any ideas where the problem is?

thanks,

Matt




More information about the D.gnu mailing list