March 01, 2007 _argptr behaves different on cross compiler | ||||
---|---|---|---|---|
| ||||
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 |
March 01, 2007 Re: _argptr behaves different on cross compiler | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matt Brandt | Matt Brandt wrote: > 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: Did you try using the portable templates instead of casting ? "To protect against the vagaries of stack layouts on different CPU architectures, use std.stdarg to access the variadic arguments:" http://www.digitalmars.com/d/function.html --anders |
Copyright © 1999-2021 by the D Language Foundation