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

Compile-Time Built-in Versions

Part of VersioningCategory


Determine your compile environment at compile time (and even output the results at compile time).

Related Example



version(DigitalMars) pragma(msg, "Compiler Vendor: Digital Mars");
version(linux) pragma(msg, "Operating System: Linux.");
version(Windows) pragma(msg, "Operating System: Microsoft Windows");
version(Win32) pragma(msg, "Microsoft Windows (32-bit)");
version(Win64) pragma(msg, "Microsoft Windows (64-bit)");

    version(Win32) {}
    else version(Win64) {}
    else pragma(msg, "Microsoft Windows (?-bit)");

version(linux) {}
else version(Windows) {}
else pragma(msg, "Operating System: Unknown");

version(X86) pragma(msg, "Processor: Intel or AMD 32-bit");     
version(AMD64) pragma(msg, "Processor: AMD 64-bit processor");     

version(LittleEndian)   pragma(msg, "byte order: least significant first");
version(BigEndian)      pragma(msg, "byte order: most significant first");

version(LittleEndian) {}
else version(BigEndian) {}
else pragma(msg, "byte order: unknown");

version(D_InlineAsm)    pragma(msg, "Inline assembler: implemented\n");

version(none)           pragma(msg, "This code is always disabled.\n");    

import std.stdio : writefln;

void main()
    writefln("Nothing needs to happen during runtime 
since the real work was done during compilation.");    


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.)

Compiler Vendor: Digital Mars
Operating System: Microsoft Windows
Microsoft Windows (32-bit)
Processor: Intel or AMD 32-bit
byte order: least significant first
Inline assembler: implemented