| |
 | Posted by Basile B. in reply to Lodovico Giaretta | Permalink Reply |
|
Basile B. 
Posted in reply to Lodovico Giaretta
| 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.
|