variadic (typesafe) args in DLL
Jarrett Billingsley
kb3ctd2 at yahoo.com
Fri Feb 8 11:20:24 PST 2008
"Bjoern" <nanali at nospam-wanadoo.fr> wrote in message
news:foi37b$19vv$1 at digitalmars.com...
> export extern (Windows) uint BinaryOrPlus(uint...)
> {
> uint result = _arguments[0];
> for (int i = 1; i < _arguments.length; i++)
> {
> result |= _arguments[i];
> }
> return result;
> }
>
> Unfortunately Error msg is :
>
> C:\dmd\projects\bsdutil>dmd -profile -odc:\dmd\projects\bsdutil\obj -ofBSDUTIL.D
> LL bsdutil.d demangle.d bsdutil.def
> bsdutil.d(110): Error: undefined identifier _arguments
> bsdutil.d(110): Error: _arguments must be an array or pointer type, not
> int
Ur typesafe variadic function, ur doin it wrong.
You declare the typesafe variadic param as so:
uint BinaryOrPlus(uint[] vals...)
then just use vals.
Typesafe variadic params are just sugar for passing an array literal. In
fact you can also pass an array reference in place of a list of params.
To that end, unless 4GL supports passing D arrays, you're going to have to
do something else.
More information about the Digitalmars-d-learn
mailing list