version pairs?

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 10 18:34:20 PDT 2016


On Sunday, April 10, 2016 13:58:17 Jay Norwood via Digitalmars-d-learn wrote:
> Seems like there should be an extra level to the version
> statement, something like version(arch,x86).
>
> I must be missing something about the intended use of the version
> statement.

In most cases that I've seen, you only need one level of version statement -
usually a version for the OS is all that's needed. The need for specifying
the architecture is _very_ rare from what I've seen. But if you need more
levels, then just nest version statements. e.g.

version(linux)
{
    version(X86)
    {
    }
    else version(X86_64)
    {
    }
}

There some places in druntime that nest like that (I think primarily to
separate the various C runtimes on systems that don't have only one), but as
it is, version statements of any kind aren't needed all that frequently in
Phobos - and when they are, it's almost inevitably because they're wrapping
C functionality. Pure D stuff tends to be system-agnostic and therefore not
version-statement heavy.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list