On Wed, Jan 02, 2019 at 05:38:41PM +0000, IM via Digitalmars-d-learn wrote: > 1- How do I do in D the equivalent of the following C++ macro? > > #define OUT_VAL(val) (count << #val << " = " << val << endl) > > In particular the #val above to the actual macro argument as a string? [...]
Try something along these lines: import std.stdio; void OUT_VAL(alias val)() { writefln("%s = %s", __traits(identifier, val), val); } void main() { int i = 123; string s = "abc"; OUT_VAL!i; OUT_VAL!s; } T -- The easy way is the wrong way, and the hard way is the stupid way. Pick one.