On Tuesday, 30 July 2013 at 01:06:39 UTC, Meta wrote:
Does this code do what you want, or are there other requirements as well?

void Pragma(alias amsg)(string file = __FILE__)
{
        pragma(msg, amsg);
}

Actually, sorry, that's the exact same code, just with some syntactic sugar. To avoid the "expression has no effect" problem, you could use an alias instead of an enum. You're getting the error when you try to use pragma in the "global" scope, right?

void Pragma(alias amsg)(string file = __FILE__)
{
    pragma(msg, amsg);
}

alias temp = Pragma!("test");

In general, D doesn't have top-level expressions like what I think you want to do here. Maybe somebody else knows a way to work around that.

Reply via email to