Borland (now CodeGear) defines unique conditional symbols for each version of Delphi which can be tested at compile time. The problem is, it's not easy to find out what the values are. Here's a table:
Version |
Conditional Symbol |
| Delphi 2007 | V185 |
| Delphi 2006 | V180 |
| Delphi 2005 | V170 |
| Delphi 8 | V160 |
| Delphi 7 | VER150 |
| Delphi 6 | VER140 |
| Delphi 5 | VER130 |
| Delphi 4 | VER120 |
| Delphi 3 | VER110 |
| Delphi 2 | VER90 |
| Delphi 1 | VER80 |
Why do we care? Once in a while we need to change the source code based on the version of Delphi being used. Conditional test $IFDEF will let us accomplish this. For example, Delphi 6 needs a windowed control's DoubleBuffered property to be turned on to prevent flickering when a TImage is redrawn. This is not necessary in Delphi 5 (I suspect a D5 "bug" that is "corrected" in D6.) Here's sample code from of a program currently being developed which fixes some TTabsheets to make things right regardless of the compiler version used.
{$IFDEF VER140}
{Delphi6?}
SimpleSheet.doublebuffered:=true;
DoubleSheet.doublebuffered:=true;
ForcedSheet.doublebuffered:=true;
{$ENDIF}
Addendum January 23, 2008: I recently started looking into switching from Delphi Version 5 to a free product, Turbo Delphi Explorer, which is Delphi 2006 with some modest restrictions. I needed to use the conditional version tests to help account for some of the differences when compiling existing programs and perhaps to maintain compatibility in the future.
I found this "wikia page" with a complete listing of compiler conditional defines for Delphi: http://delphi.wikia.com/wiki/Borland_Compiler_Conditional_Defines so thought I record it here for future reference.
| Created: September 15, 2002 |
Modified: November 07, 2008 |