I think this should work: string s = "int x;"; mixin(s);
void main() { } But I get: testtest.d(11): Error: argument to mixin must be a string, not (s) I get a similar error with the template example from the docs: template GenStruct(string Name, string M1) { string GenStruct = "struct " ~ Name ~ "{ int " ~ M1 ~ "; }"; } mixin(GenStruct!("Foo", "bar")); void main() { } testtest.d(27): Error: argument to mixin must be a string, not (GenStruct) This is really weird, I swear it worked for me a couple of days ago. :s Maybe I accidentally modified a library file, so I'll have a look. Meanwhile can someone succesfully compile these?