digitalmars.D.learn - Is __VERSION__ cross-compiler compatible?
- Andrej Mitrovic (7/7) Nov 21 2011 I've seen this code used somwhere:
- Stewart Gordon (11/18) Nov 30 2011 It's in the language spec, so obviously it's part of the language. But ...
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.
Nov 21 2011
On 22/11/2011 01:10, 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?It's in the language spec, so obviously it's part of the language. But since it's defined to be the _compiler_ version, values of __VERSION__ are compiler-specific. But with the number of versions the language has been through, it would be nice if they all had numbers.... http://tinyurl.com/qayz9wAlso, does DMD1 define this too?Yes.I'm trying to retain compatibility of some D1 sample code but introduce D2 support as well.version(D_Version2) However, because parsing happens before CC, you can't use D2-specific syntax anywhere in a code file that needs to be D1-compatible, unless you wrap it in a string mixin. Stewart.
Nov 30 2011