Can I do an or in a version block?

Jacob Carlborg doob at me.com
Thu Mar 8 00:21:43 PST 2012


On 2012-03-08 06:38, Tyler Jameson Little wrote:
> I would like to do something like this:
>
> version (linux || BSD) {
> // do something...
> } else {
> version (Windows) {
> // do something else
> } else {
> // do something else
> assert(false, "Unsupported operating system");
> }
> }
>
> The only way I've been able to do this, is by splitting up the two
> versions and repeat code.
>
> Is there a better way to do this? A static if can do this, so is there a
> way that I can use a static if somehow?

A workaround is to use static if constants, here's a start:

https://github.com/jacob-carlborg/mambo/blob/master/util/Version.d

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list