version and debug statements
Anders F Björklund
afb at algonet.se
Fri May 12 16:11:36 PDT 2006
Walter Bright wrote:
>>> DMD supports Windows and Linux; Unix is neither. For a compiler which
>>> targets the Unix operating system, it should set the Unix version.
>>
>> It does... I was just hoping to be able to use the same code for both ?
>
> I know it seems like the right thing to do to use the same code for both
> operating systems. I'm going to argue that this is a case where
> copy/paste might be better.
I began copying/pasting, then. It's going to be three active versions:
* version (Windows) // for all
* version (linux) // for DMD
* version (Unix) // for GDC
version(Unix) should probably come before version(linux), since older
GDC versions came with a non-existent or incomplete std.c.linux.linux.
version (Windows)
{
private import std.c.windows.windows;
}
else version (Unix)
{
private import std.c.unix.unix;
}
else version (linux)
{
private import std.c.linux.linux;
}
else static assert(0);
It will end up in a LOT of duplicated code, though. Previously it was
being shared with the Unix version by using alias and setting version:
else version (Unix)
{
private import std.c.unix.unix;
alias std.c.unix.unix unix;
}
else version (linux)
{
version = Unix;
private import std.c.linux.linux;
alias std.c.linux.linux unix;
}
That way both DMD and GDC could share the "Unix" section of the code ?
(I'm not going to use "darwin" here, that'll be way too many versions)
--anders
More information about the Digitalmars-d
mailing list