[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
| 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:
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?}
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 I record it here for future reference.
November 7, 2013: I just acquired Delphi XE5 and will be looking into making programs compile under multiple versions. The table above has been updated with the conditional symbols for versions from 2007 through XE5 in preparation for the experiment.
I also added "Compilerversion" values to the table. Compilerversion is a global constant initialized for versions beginning with Delphi 6. Generating conditional code will be cleaner using this constant because we can test for versions ">=" or "<=" a specific version in a single test. For example, beginning with XE (Compiler version 22), the date/time formatting variables previously embedded in the SysUtils unit now exist within a FormatSettings record within SysUtils. So if your program previously referenced "ThousandsSeparator" for example, it must now reference FormatSettings.ThousandsSeparator. Here's the code change for our UBigIntsV3 unit when it is building a large integer string representation with the appropriate thousands separators:
{$IF
CompilerVersion<22}
With this change, UBigIntsV3 should compile successfully for all Delphi versions after Delphi 5.
November 24, 2013: It looks like there will be a number of differences between my Delphi 7 and Delphi XE5 versions that can be accommodated using the {$IF} conditional compilation technique described above. A new Delphi 7, XE5 differences page has been created to record differences as I find them. This will be a useful reference for me and perhaps of interest to others upgrading their Delphi.
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |