Delphiversions.inc[]
The following code defines DelphiXx and DelphiXx_up conditional defines depending on the Borland Compiler Conditional Defines. Copy this into a file called Delphiversions.inc and add
{$include 'Deplphiversions.inc'}
into any unit that needs to determine which Delphi version is used to compile it.
You can then use e.g.
{$IFDEF Delphi6_up} // some code that only works with Delphi 6 and newer {$WARN unsafe_type off} {$WARN unsafe_code off} {$WARN unsafe_cast off} {$ENDIF} {$IFNDEF Delphi6_up} // some code that is only for Delphi 5 and older {$endif}
Note, that the DelphiXxUp cond. define is only kept for backwards compatibility. You should use the DelphiXx_up define instead because that is also available in jedi.inc while the define without _ is not.
This is a very simple version of such a file. See jedi.inc for a more comprehensive version.
// to make it easier to find out which version of Delphi we are using {$IFDEF VER80} {$DEFINE Delphi1} {$DEFINE Delphi1_up} {$ENDIF} {$IFDEF VER90} {$DEFINE Delphi2} {$DEFINE Delphi2_up} {$ENDIF} {$IFDEF VER100} {$DEFINE Delphi3} {$DEFINE Delphi3_up} {$ENDIF} {$IFDEF VER120} {$DEFINE Delphi4} {$DEFINE Delphi4_up} {$ENDIF} {$IFDEF VER130} {$DEFINE Delphi5} {$DEFINE Delphi5_up} {$ENDIF} {$IFDEF CONDITIONALEXPRESSIONS} // Delphi 6 and up support the CompilerVersion constant and the IF conditional define // This has the advantage that new Delphi versions will automatically be supported by this // include file. Of course this won't help with fatures newly introduced by these versions {$IF CompilerVersion >= 14} {$DEFINE Delphi6} {$DEFINE Delphi6_up} {$IFEND} {$IF CompilerVersion >= 15} {$DEFINE Delphi7} {$DEFINE Delphi7_up} {$IFEND} // VER160 was Delphi 8 for .NET only {$IF CompilerVersion >= 17} {$DEFINE Delphi2005} {$DEFINE Delphi2005_up} {$IFEND} {$IF CompilerVersion >= 18} {$DEFINE Delphi2006} {$DEFINE Delphi2006_up} {$IFEND} {$IFDEF VER185} {$DEFINE Delphi2007} {$DEFINE Delphi2007_up} {$ENDIF} {$IF CompilerVersion >= 20} {$DEFINE Delphi2009} {$DEFINE Delphi2009_up} {$IFEND} {$IF CompilerVersion >= 21} {$DEFINE Delphi2010} {$DEFINE Delphi2010_up} {$IFEND} {$IF CompilerVersion >= 22} {$DEFINE DelphiXE} {$DEFINE DelphiXE_up} {$IFEND} {$IF CompilerVersion >= 23} {$DEFINE DelphiXE2} {$DEFINE DelphiXE2_up} {$IFEND} {$IF CompilerVersion >= 24} {$DEFINE DelphiXE3} {$DEFINE DelphiXE3_up} {$IFEND} {$IF CompilerVersion >= 25} {$DEFINE DelphiXE4} {$DEFINE DelphiXE4_up} {$IFEND} {$IF CompilerVersion >= 26} {$DEFINE DelphiXE5} {$DEFINE DelphiXE5_up} {$IFEND} //{$IFDEF VER275} //{$DEFINE APPMETHOD} //{$ENDIF} {$IF CompilerVersion >= 27} {$DEFINE DelphiXE6} {$DEFINE DelphiXE6_up} {$IFEND} {$IF CompilerVersion >= 28} {$DEFINE DelphiXE7} {$DEFINE DelphiXE7_up} {$IFEND} {$IF CompilerVersion >= 29} {$DEFINE DelphiXE8} {$DEFINE DelphiXE8_up} {$IFEND} // Embarcadero changed the naming scheme again. // It's Delphi 10 Seattle now // We assume that they will increment that number // for now and declare a DelphiXnn define for this. // Let's see what the next version will be called... {$IF CompilerVersion >= 30} {$DEFINE DelphiX10} {$DEFINE DelphiX10_up} {$DEFINE DelphiX100} {$DEFINE DelphiX100_up} {$IFEND} // It's Delphi 10.1 Berlin now {$IF CompilerVersion >= 31} {$DEFINE DelphiX101} {$DEFINE DelphiX101_up} {$IFEND} {$IF CompilerVersion >= 32} {$DEFINE DelphiX102} {$DEFINE DelphiX102_up} {$IFEND} {$IF CompilerVersion >= 33} {$DEFINE DelphiX103} {$DEFINE DelphiX103_up} {$IFEND} {$IF CompilerVersion >= 34} {$DEFINE DelphiX104} {$DEFINE DelphiX104_up} {$IFEND} // Delphi 11, we assume, that they will follow up with 11.1, so lets start with 3 digits (they didn't) // (they didn't, but we will continue with 3 digits) {$IF CompilerVersion >= 35} {$DEFINE DelphiX110} {$DEFINE DelphiX110_up} {$IFEND} // Delphi 12 {$IF CompilerVersion >= 36} {$DEFINE DelphiX120} {$DEFINE DelphiX120_up} {$IFEND} {$ENDIF CONDITIONALEXPRESSIONS} // now add DelphiXx_Up constants for all previous versions based on the highest version found {$IFDEF DelphiX120_up} {$DEFINE DelphiX120up} {$DEFINE DelphiX110_up} {$DEFINE DelphiX110up} {$ENDIF} {$IFDEF DelphiX110_up} {$DEFINE DelphiX110up} {$DEFINE DelphiX104_up} {$DEFINE DelphiX104up} {$ENDIF} {$IFDEF DelphiX104_up} {$DEFINE DelphiX104up} {$DEFINE DelphiX103_up} {$DEFINE DelphiX103up} {$ENDIF} {$IFDEF DelphiX103_up} {$DEFINE DelphiX103up} {$DEFINE DelphiX102_up} {$DEFINE DelphiX102up} {$ENDIF} {$IFDEF DelphiX102_up} {$DEFINE DelphiX102up} {$DEFINE DelphiX101_up} {$DEFINE DelphiX101up} {$ENDIF} {$IFDEF DelphiX101_up} {$DEFINE DelphiX101up} {$DEFINE DelphiX10_up} {$DEFINE DelphiX10up} {$ENDIF} {$IFDEF DelphiX10_up} {$DEFINE DelphiX10up} {$DEFINE DelphiXE8_up} {$DEFINE DelphiXE8up} {$ENDIF} {$IFDEF DelphiXE8_up} {$DEFINE DelphiXE8up} {$DEFINE DelphiXE7_up} {$DEFINE DelphiXE7up} {$ENDIF} {$IFDEF DelphiXE7_up} {$DEFINE DelphiXE7up} {$DEFINE DelphiXE6_up} {$DEFINE DelphiXE6up} {$ENDIF} {$IFDEF DelphiXE6_up} {$DEFINE DelphiXE6up} {$DEFINE DelphiXE5_up} {$DEFINE DelphiXE5up} {$ENDIF} {$IFDEF DelphiXE5_up} {$DEFINE DelphiXE5up} {$DEFINE DelphiXE4_up} {$DEFINE DelphiXE4up} {$ENDIF} {$IFDEF DelphiXE4_up} {$DEFINE DelphiXE4up} {$DEFINE DelphiXE3_up} {$DEFINE DelphiXE3up} {$ENDIF} {$IFDEF DelphiXE3_up} {$DEFINE DelphiXE3up} {$DEFINE DelphiXE2_up} {$DEFINE DelphiXE2up} {$ENDIF} {$IFDEF DelphiXE2_up} {$DEFINE DelphiXE2up} {$DEFINE DelphiXE_up} {$DEFINE DelphiXEup} {$ENDIF} {$IFDEF DelphiXE_up} {$DEFINE DelphiXEup} {$DEFINE Delphi2010_up} {$DEFINE Delphi2010up} {$ENDIF} {$IFDEF Delphi2010_up} {$DEFINE Delphi2010up} {$DEFINE Delphi2009_up} {$DEFINE Delphi2009up} {$ENDIF} {$IFDEF Delphi2009_up} {$DEFINE Delphi2009up} {$DEFINE Delphi2007_up} {$DEFINE Delphi2007up} {$ENDIF} {$IFDEF Delphi2007_up} {$DEFINE Delphi2007up} {$DEFINE Delphi2006_up} {$DEFINE Delphi2006up} {$ENDIF} {$IFDEF Delphi2006_up} {$DEFINE Delphi2006up} {$DEFINE Delphi2005_up} {$DEFINE Delphi2005up} {$ENDIF} {$IFDEF Delphi2005_up} {$DEFINE Delphi2005up} {$DEFINE Delphi7_up} {$DEFINE Delphi7up} {$ENDIF} {$IFDEF Delphi7_up} {$DEFINE Delphi7up} {$DEFINE Delphi6_up} {$DEFINE Delphi6up} {$ENDIF} {$IFDEF Delphi6_up} {$DEFINE Delphi6up} {$DEFINE Delphi5_up} {$DEFINE Delphi5up} {$ENDIF} {$IFDEF Delphi5_up} {$DEFINE Delphi5up} {$DEFINE Delphi4_up} {$DEFINE Delphi4up} {$ENDIF} {$IFDEF Delphi4_up} {$DEFINE Delphi4up} {$DEFINE Delphi3_up} {$DEFINE Delphi3up} {$ENDIF} {$IFDEF Delphi3_up} {$DEFINE Delphi3up} {$DEFINE Delphi2_up} {$DEFINE Delphi2up} {$ENDIF} {$IFDEF Delphi2_up} {$DEFINE Delphi2up} {$DEFINE Delphi1_up} {$DEFINE Delphi1up} {$ENDIF} {$IFDEF Delphi1_up} {$DEFINE Delphi1up} {$ENDIF}