www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - List defined version specifications

reply Lodovico Giaretta <lodovico giaretart.net> writes:
Hi!

A simple question: is there a way to list all defined version 
specifications?

Something like:

     pragma(msg, __traits(allVersions));

Example output (DMD on Ubuntu x64, release build):

     [all, D_InlineAsm_X86_64, X86_64, Posix, linux, DigitalMars, 
CRuntime_Glibc, D_Version2, LittleEndian, D_LP64, D_HardFloat, 
D_SIMD, D_NoBoundsChecks, ELFv2]

Thank you in advance.
Oct 19 2016
next sibling parent Basile B. <b2.temp gmx.com> writes:
On Wednesday, 19 October 2016 at 10:25:51 UTC, Lodovico Giaretta 
wrote:
 Hi!

 A simple question: is there a way to list all defined version 
 specifications?

 Something like:

     pragma(msg, __traits(allVersions));

 Example output (DMD on Ubuntu x64, release build):

     [all, D_InlineAsm_X86_64, X86_64, Posix, linux, 
 DigitalMars, CRuntime_Glibc, D_Version2, LittleEndian, D_LP64, 
 D_HardFloat, D_SIMD, D_NoBoundsChecks, ELFv2]

 Thank you in advance.
No, but they can be generated with a string mixin: static __gshared string[] definedVersions; enum predefinedVersions = [ "ARM_Thumb","assert","ELFv1","ELFv2", "HPPA","HPPA64","Posix","unittest", "Win32","Win64","Windows","X86","X86_64" ]; alias addDefinedVer = (ver) => `version(`~ ver ~`) definedVersions~="` ~ ver ~ `";`; string genDefinedVersions() { import std.meta: aliasSeqOf; import std.range: iota; string result; foreach(i; aliasSeqOf!(iota(0, predefinedVersions.length))) result ~= addDefinedVer(predefinedVersions[i]); return result; } void main() { mixin(genDefinedVersions); } The problem being that they are not available at compile time.
Oct 19 2016
prev sibling parent Johan Engelen <j j.nl> writes:
On Wednesday, 19 October 2016 at 10:25:51 UTC, Lodovico Giaretta 
wrote:
 Hi!

 A simple question: is there a way to list all defined version 
 specifications?
Perhaps not what you are looking for but on the commandline:
  bin/ldc2 -v test.d
... predefs LDC all D_Version2 assert X86_64 D_InlineAsm_X86_64 D_HardFloat LittleEndian D_LP64 D_PIC OSX darwin Posix D_ObjectiveC LDC_LLVM_309 -Johan
Oct 19 2016