compilers w/ different language features: version block
kdevel
kdevel at vogtner.de
Sun Feb 25 00:36:16 UTC 2018
A code fragment using static foreach
https://forum.dlang.org/thread/jiefcxwqbjzqnmtazkwy@forum.dlang.org#post-beruryblsptnunsowjph:40forum.dlang.org
does not compile with the current GDC (GCC 4.9.4 and 5.5.0). I
tried to encapsulate this code into a version block but GDC still
checks the syntax. Is there any more elegant way besides of using
a mixin?:
version (DigitalMars) {
pragma (msg, "DMD");
mixin (`
enum typenames = ["float", "double", "real", "short",
"int", "long"];
static foreach (s; typenames) {
pragma (msg, s);
disp[s] = mixin ("&mymain!" ~ s);
}
`);
}
More information about the Digitalmars-d-learn
mailing list