Note: This website is archived. For up-to-date information about D projects and development, please visit

Built-in Versions

Part of VersioningCategory


Determine your compile environment at compile time.

Related Example

Even the output can be done at compile time: CompileTimeBuiltInVersionsExample


import std.stdio : writef, writefln;

void main()
    version(DigitalMars) writefln("Compile vendor: Digital Mars");
    else writefln("Compile vendor: unknown");

    version(linux) writefln("Operating system: Linux");
        writef("Operating system: Windows ");
        version(Win32) writefln("(32-bit)");
        version(Win64) writefln("(64-bit)");        

    version(linux) {}
    else version(Windows) {}
    else writefln("Operating system: unknown");
    version(X86) writefln("Processor: Intel or AMD (32-bit)");     
    version(X86_64) writefln("Processor: AMD or Intel (64-bit)");

    version(LittleEndian)    writefln("Byte order: least significant first");
    version(BigEndian)       writefln("Byte order: most significant first");

    version(D_Coverage)      writefln("Coverage analyzer: implemented");
    version(D_InlineAsm)     writefln("Inline assembler: implemented");
    version(D_InlineAsm_X86) writefln("Inline assembler for X86: implemented");

    /* used to just disable a section of code  */
    version(none)            writefln("This version is always disabled.");

    /* the opposite of none */ 
    version(all)             writefln("This version is always enabled."); 


Tested with Digital Mars D Compiler v0.177 on Windows 2000.

Sample Output

(The output will depend on the operating system and architecture that the program is run on.)

Compile vendor: Digital Mars
Operating system: Windows (32-bit)
Processor: Intel or AMD (32-bit)
Byte order: least significant first
Inline assembler: implemented
Inline assembler for X86: implemented
This version is always enabled.