[Issue 7417] One-definition rule for version specification - allow version expressions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 10 18:45:02 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=7417

anonymous4 <dfj1esp02 at sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec

--- Comment #10 from anonymous4 <dfj1esp02 at sneakemail.com> ---
Workaround:
---
template Defined(string s)
{
    mixin(`version(`~s~`)enum Defined=true;else enum Defined=false;`);
}

struct SVersion
{
    alias opDispatch(string s)=Defined!s;
}
enum Version=SVersion();

int main()
{
    static if(Version.OSX)writeln("running OSX");
    else writeln("no");
    return 0;
}
---

--


More information about the Digitalmars-d-bugs mailing list