Mixin Expressions, can't evalutate string variable

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Aug 5 12:03:48 PDT 2010


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?



More information about the Digitalmars-d mailing list