[Issue 7417] One-definition rule for version specification - allow version expressions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Apr 26 14:01:21 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=7417

Witold Baryluk <baryluk at smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |baryluk at smp.if.uj.edu.pl

--- Comment #6 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> ---
Hi. Any update on this.

I was just trying to compiled phobos using gdc on arm64, and of course first
thing that failed was a static assert in
libdruntime/core/sys/posix/sys/socket.d that do have about 10 different semi
duplicated version branches.

I would really want to say:

version (ARM || AArch64 || PPC || PPC64 || MIPS32 || MIPS64 || X86 || X86_64) {
  ...
} else version (SomethingSpecial) {
  ...
} else {
  static assert(0);
}


That would be good enough in most cases.

Support for more elaborate conditions would be nice too.

instead of

version (A) {
} else {
  somethign special.
}


version (!A) {
  something special.
}


or 

version (A) {
version (B) {
  something.
}
}
version (A && B) {
  something.
}

It is probably possible to implement what I want using mixing and putting
common code in the template, and then expand

version (ARM || AArch64 || PPC || PPC64 || MIPS32 || MIPS64 || X86 || X86_64) {


into separate branches with mixed-in template. Still I fell, explicit booleans
support on versions would be nicer.

BTW. The mentioned file also shows almost the same enums in the OSX and FreeBSD
branches, so maybe in this case it is worth doing this via mixin, as the OSX
and FreeBSD branches cannot be really folded easily into one version (OSX ||
FreeBSD) branch. Same with Android (with do have same enum values as Linux).

--


More information about the Digitalmars-d-bugs mailing list