mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-21 19:29:03 +02:00
[svn r61] Added support for D-style variadic functions :)
This commit is contained in:
18
test/vararg2.d
Normal file
18
test/vararg2.d
Normal file
@@ -0,0 +1,18 @@
|
||||
module vararg2;
|
||||
|
||||
void func(...)
|
||||
{
|
||||
assert(_arguments.length == 2);
|
||||
assert(_arguments[0] is typeid(int));
|
||||
int a = *cast(int*)_argptr;
|
||||
_argptr += int.sizeof;
|
||||
assert(_arguments[1] is typeid(int));
|
||||
a += *cast(int*)_argptr;
|
||||
_argptr += int.sizeof;
|
||||
assert(a == 3);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
func(1,2);
|
||||
}
|
||||
19
test/vararg3.d
Normal file
19
test/vararg3.d
Normal file
@@ -0,0 +1,19 @@
|
||||
module vararg3;
|
||||
|
||||
import std.stdarg;
|
||||
|
||||
void func(...)
|
||||
{
|
||||
assert(_arguments.length == 3);
|
||||
assert(_arguments[0] is typeid(int));
|
||||
assert(_arguments[1] is typeid(float));
|
||||
assert(_arguments[2] is typeid(long));
|
||||
assert(va_arg!(int)(_argptr) == 4);
|
||||
assert(va_arg!(float)(_argptr) == 2.5f);
|
||||
assert(va_arg!(long)(_argptr) == 42L);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
func(4, 2.5f, 42L);
|
||||
}
|
||||
Reference in New Issue
Block a user