Version bug?

Adam Ruppe destructionator at gmail.com
Fri Aug 20 17:21:11 PDT 2010


Last message in a row, I promise.

I just determined a work around for this - use a global variable. (the
config.d file defines several global variables already, but it is
stuff like companyName, domainName, etc.).

A global enum actually:

====
version(clientA)
    enum bool withFeatureX = true;
===
other file:
=====
static if(withFeatureX) {
 // implement feature X
}
=====


This does some wonky things if the braces are misplaced that the
version statement caught, but on the upside, my config.d file still
works and the compiler catches me if I try to use an undeclared
feature. (On the other hand, I have to specify true or false for each
client, but that's not a big hassle.)

It still appears to do the same job: compile out the code blocks for
those clients who aren't supposed to get the feature.

It isn't perfect like version(){} was (in my head), but it's not so
bad, I can live with this.


More information about the Digitalmars-d mailing list