Thread overview
Re: Is __VERSION__ cross-compiler compatible?
Nov 22, 2011
Jonathan M Davis
Nov 22, 2011
Andrej Mitrovic
Nov 22, 2011
Andrew Wiley
November 22, 2011
On Tuesday, November 22, 2011 02:10:51 Andrej Mitrovic wrote:
> I've seen this code used somwhere:
> 
> static if (__VERSION__ > 2048)
> {
> }
> 
> Does this work for all compilers, or is it DMD-specific? Also, does DMD1 define this too? I'm trying to retain compatibility of some D1 sample code but introduce D2 support as well.

I'd expect it to be compiler-specific.

- Jonathan M Davis
November 22, 2011
GDC does seem to use this, now that I've tested it:

D:\dev\code\d_code>gdc test.d
1067L

D:\dev\code\d_code>gdc -v2 test.d
2052L

I've found the docs, it states this is a compiler token: http://d-programming-language.org/lex.html (section Special Tokens)

But being able to target a *language version* in a compiler-neutral way would be great. I don't know if LDC does the same thing as GDC though.
November 22, 2011
On Mon, Nov 21, 2011 at 8:16 PM, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> GDC does seem to use this, now that I've tested it:
>
> D:\dev\code\d_code>gdc test.d
> 1067L
>
> D:\dev\code\d_code>gdc -v2 test.d
> 2052L
>
> I've found the docs, it states this is a compiler token: http://d-programming-language.org/lex.html (section Special Tokens)
>
> But being able to target a *language version* in a compiler-neutral way would be great. I don't know if LDC does the same thing as GDC though.
>

Odds are good that this value is part of the frontend, in which case it would be identically in LDC and GDC.