Foo:
Hey guys. Can someone explain me, why this code does only works with the inline assembler version but not with the mixin?
You need mixin(), it's unfortunate this gives no error messages: import std.string: format; enum Vala(uint count, alias arr) = format(" asm { sub ESP, %d; // Reserve 'count' bytes mov %s, %d; // Set a.length = 'count' mov %s + 4, ESP; // Set &a[0] to reserved bytes }", count, arr.stringof, count, arr.stringof); void main() { import std.stdio: writeln; ubyte[] a; a.length.writeln; static if (false) { asm { sub ESP, 1000; // Reserve 1000 bytes mov a, 1000; // Set a.length = 1000 mov a + 4, ESP; // Set &a[0] to reserved bytes } } else { mixin(Vala!(1000, a)); } a.length.writeln; } Bye, bearophile