Implicit alloca for static arrays
Lionello Lunesu
lio at remove.lunesu.com
Thu Mar 23 07:33:50 PST 2006
If you'd ask me, this should definately be included before 1.0:
# void somefunc( uint i ) {
# char[i] array; // creates static array but with run-time length (*)
# }
This can currently be done by using alloca (for the record:)
# import std.c.stdlib;
# void somefunc( uint i ) {
# char[] array = (cast(char*)alloca(char.sizeof * i))[0..i];
# }
which works fine, as long as you don't append / resize the array.
L.
(*) this code generates 4 identical compiler errors:
Integer constant expression expected instead of (events).length
More information about the Digitalmars-d
mailing list