You can use the mixin operator to convert a string to code at compile time, for example:
mixin("value = 123;");
The following function generates a string containing the statement, which will be the closest equivalent to your C macro:
string soConvenient(alias A)() { return std.string.format( 'value = someFunc(%1$s, "%1$s");', __traits(identifier, A)); }
What would you use then:
mixin(soConvenient!x);
source share