digitalmars.D.learn - D_Version2 problem
- Hoenir (3/3) Jan 18 2009 The D_Version2 version identifier doesn't work properly for me.
- Stewart Gordon (18/23) Jan 18 2009 Works for me, as this code demonstrates:
- Bill Baxter (4/7) Jan 18 2009 I just tried with DMD 1.037 and it worked fine.
- Hoenir (3/5) Jan 18 2009 Figured out what was wrong. I used const and stuff.
- Sergey Gromov (15/20) Jan 18 2009 Works for me.
- David Ferenczi (7/27) May 16 2009 The behaviour is a bit ambigous, since in compile time every version blo...
- David Ferenczi (4/31) Jun 11 2009 compile
- Robert Fraser (13/43) Jun 11 2009 This has been discussed many times over. It's a "feature" according to
- David Ferenczi (6/53) Jun 11 2009 Many thanks for your answer. I should have missed this discussion. I sti...
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?
Jan 18 2009
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 bugWorks 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.
Jan 18 2009
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
Jan 18 2009
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.
Jan 18 2009
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.dv1
Jan 18 2009
== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleSun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: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, DavidThe 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.dv1
May 16 2009
== Quote from David Ferenczi (raggae ferenczi.net)'s article== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleinterpreted!Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote:The behaviour is a bit ambigous, since in compile time every version block getsThe 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.dv1So you cannot put D2 only code in the version(D_Version2) {} block, if you want tocompileyour source with D1. I don't know if it's a bug or a feature. Regards, DavidShoudl I file a bug report?
Jun 11 2009
David Ferenczi wrote:== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleThis 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.Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: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, DavidThe 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.dv1
Jun 11 2009
Robert Fraser wrote:David Ferenczi wrote: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?== Quote from Sergey Gromov (snake.scaly gmail.com)'s articleThis 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.Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: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, DavidThe 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.dv1
Jun 11 2009