D_Version2 problem

David Ferenczi raggae at ferenczi.net
Sat May 16 06:02:32 PDT 2009


== Quote from Sergey Gromov (snake.scaly at gmail.com)'s article
> Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote:
> > The D_Version2 version identifier doesn't work properly for me.
> > Tried compiling with dmd 1.039. D_Version2 is set even if I pass -v1 to it.
> >
> > Is this a bug or am I doing something wrong?
> Works for me.
> It's hard to tell if you're doing something wrong until you post your
> test code.
> ----8<------ test.d
> version(D_Version2)
> {
>   pragma(msg, "v2");
> }
> else
> {
>   pragma(msg, "v1");
> }
> ----8<------
> > dmd -c test.d
> v1

The behaviour is a bit ambigous, since in compile time every version block gets interpreted!
So you cannot put D2 only code in the version(D_Version2) {} block, if you want to compile
your source with D1.

I don't know if it's a bug or a feature.

Regards,
David


More information about the Digitalmars-d-learn mailing list