version and debug statements
Walter Bright
newshound at digitalmars.com
Thu May 11 09:44:34 PDT 2006
Anders F Björklund wrote:
> I'm still naively hoping for both of "version (Unix)"
DMD supports Windows and Linux; Unix is neither. For a compiler which
targets the Unix operating system, it should set the Unix version.
> and "version (!Windows)" to be defined and legal in D.
In C and C++, I often see:
#if !WIN32
when what is really meant is:
#if linux
i.e. the former is almost always a bug waiting to happen (when someone
tries to compile for a third operating system). Versions should be "this
build is for this configuration" rather than "this build is not for that
configuration."
One can also write:
version (ThisFeature)
{
}
else
{
version = ThatFeature;
}
...
version (ThatFeature)
...
For an example of why D is this way, see the sources to the Hans Boehm
garbage collector, where the complex thicket of #if's makes it extremely
difficult to see exactly what is being compiled.
More information about the Digitalmars-d
mailing list