views:

2995

answers:

7

In Delphi 2010, if I want to do this:

{$IFDEF VER999}
//some delphi 2010-specific code here
{$ENDIF}

What version # do I need to use in place of "999"?

+11  A: 

{$IFDEF VER210}

Red Haze
This file almost always contains the latest defines: http://jcl.svn.sourceforge.net/viewvc/jcl/trunk/jcl/source/include/jedi.inc?view=markup
Jeroen Pluimers
+14  A: 

Just for completeness, I have found a full list as of D2007, and added the more recent ones.

In Delphi 2007, VER180 and VER185 are both defined. This was for backward compatibility with Delphi 2006, and to make sure you could also detect D2007 specifically.

I'm not sure why they did that between '06 and '07, but not for other releases. Seems inconsistent to me (but it isn't - see Barry Kelly's comment below). But at any rate, the full list is like this:

{$IFDEF VER80}  - Delphi 1
{$IFDEF VER90}  - Delphi 2
{$IFDEF VER100} - Delphi 3
{$IFDEF VER120} - Delphi 4
{$IFDEF VER130} - Delphi 5
{$IFDEF VER140} - Delphi 6
{$IFDEF VER150} - Delphi 7
{$IFDEF VER160} - Delphi 8
{$IFDEF VER170} - Delphi 2005
{$IFDEF VER180} - Delphi 2006
{$IFDEF VER180} - Delphi 2007
{$IFDEF VER185} - Delphi 2007
{$IFDEF VER200} - Delphi 2009
{$IFDEF VER210} - Delphi 2010
{$IFDEF VER220} - Delphi XE
JosephStyons
The thing between 2006 and 2007 is that the compiler in 2007 used the same DCU format, so people's components would still work.
Barry Kelly
A: 

It was done like this for Delphi 2007 because its VCL is compatible with Delphi 2006's VCL - no other version of Delphi has ever been backwards compatible like this before.

Andreas Toth
+8  A: 

If you're working with Delphi 6 and later, you can use CompilerVersion:

{$IF CompilerVersion >= 18.5}
//some code only compiled for Delphi 2007 and later
{$IFEND}
Delphi XE   - 22
Delphi 2010 - 21
Delphi 2009 - 20
Delphi 2007 - 18.5
Delphi 2006 - 18
Delphi 2005 - 17
Delphi 8    - 16
Delphi 7    - 15
Delphi 6    - 14
jasonpenny
+2  A: 

Here is a wiki page with conditional defines.

Bruce McGee
A: 

THANKS A LOT PARTNER

René
A: 

Wrong Comment added by accident :-)

Alf Christophersen