Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
January 18, 2009 D_Version2 problem | ||||
---|---|---|---|---|
| ||||
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? |
January 18, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hoenir | 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 Works for me, as this code demonstrates: ---------- import std.stdio; void main() { version (D_Version2) { writefln("D2"); } else { writefln("D1"); } } ---------- > or am I doing something wrong? Possibly: - Inadvertently running the D2 compiler when you intended to run the D1 compiler - Misunderstanding how conditional compilation in D works .... Stewart. |
January 18, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hoenir | On Mon, Jan 19, 2009 at 6:28 AM, Hoenir <mrmocool@gmx.de> 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?
>
I just tried with DMD 1.037 and it worked fine.
How are you using it?
--bb
|
January 18, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hoenir | 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 |
January 18, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bill Baxter | Bill Baxter schrieb:
> How are you using it?
>
Figured out what was wrong. I used const and stuff.
Using a mixin now to bypass the problem.
|
May 16, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sergey Gromov | == Quote from Sergey Gromov (snake.scaly@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
|
June 11, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Ferenczi | == Quote from David Ferenczi (raggae@ferenczi.net)'s article > == Quote from Sergey Gromov (snake.scaly@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 Shoudl I file a bug report? |
June 11, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Ferenczi | David Ferenczi wrote:
> == Quote from Sergey Gromov (snake.scaly@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
This has been discussed many times over. It's a "feature" according to Walter, and there's some sense to it (since D code is supposed to be parseable without doing semantic analysis, and versions can require arbitrary ammounts of semantic analysis (like CTFE) to determine). If you want to have D2 code you need to use a mixin:
version(D_Version2) {
mixin("const(char)[] x;");
} else {
char[] x;
}
Note that the -v1 switch reverts to the (rather arbitrary) D version 1.00, while new D features were being added through (I think) 1.014.
|
June 11, 2009 Re: D_Version2 problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Fraser | Robert Fraser wrote:
> David Ferenczi wrote:
>> == Quote from Sergey Gromov (snake.scaly@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
>
> This has been discussed many times over. It's a "feature" according to Walter, and there's some sense to it (since D code is supposed to be parseable without doing semantic analysis, and versions can require arbitrary ammounts of semantic analysis (like CTFE) to determine). If you want to have D2 code you need to use a mixin:
>
> version(D_Version2) {
> mixin("const(char)[] x;");
> } else {
> char[] x;
> }
>
> Note that the -v1 switch reverts to the (rather arbitrary) D version
> 1.00, while new D features were being added through (I think) 1.014.
Many thanks for your answer. I should have missed this discussion. I still think, that it should be possible to skip the code blocks, which are behind not met version conditons. Maybe an extra compiler switch?
Do I presume correctly that in case of using a mixin the literal won't be interpreted, and that's why it doesn't cause any problem?
|
Copyright © 1999-2021 by the D Language Foundation