I can test that DMD is compiling the given code using version(DMD){}
, but how can I check which version of it? (2.66/2.65 etc)
More concisely, I want to check that the @nogc
modifier exists,
and if not - define a dummy one.
I came up with a workaround:
static if(!__traits(compiles, ()@nogc{}))
{
struct nogc;
}
but is there a better way? for example even checking directly for the existence of that specific modifier?
You can use the predefined __VERSION__
constant.
See also the std.compiler module (version_major
and version_minor
, specifically) for an easier way to use it.
However, your workaround might be a better approach. It will allow the code to work correctly even for compiler builds between released versions.