variadic parameter in DLL func. Better example
Bjoern
nanali at nospam-wanadoo.fr
Fri Feb 8 09:09:55 PST 2008
Hi,
I hope that I can write a small utility DLL which offers support for :
BinaryOrPlus(WS_TABSTOP, WS_CHILD, WS_CLIPSIBLINGS)
Why ? Because my 4GL has no binary OR operator (just a function) so this
code fragment will not work :
x is unsigned int = WS_TABSTOP | WS_CHILD | WS_CLIPSIBLINGS // etc.
Instead I have to use :
(BinaryOr(BinaryOr(WS_TABSTOP , WS_CHILD), WS_CLIPSIBLINGS) // stinks !
I hope it is possible to create something similar to :
// yep this would be smart, but ...
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
Same result in case that I use :
================================
export extern (Windows) uint BinaryOrPlus(uint firstarg, ...)
{
uint result = firstarg; //_arguments[0];
for (int i = 1; i < _arguments.length; i++)
{
result |= *cast(uint *)_argptr;
_argptr += uint.sizeof;
}
return result;
}
????*$ Use Tango Bjoern
More information about the Digitalmars-d-learn
mailing list