There are various ways for Delphi code to verify what features are available.
Historically, testing for the existence of VER###
defines with $IFDEF
or $IFNDEF
is the oldest means, and as of Delphi 6, you can also test for the existence and values of identifiers is $IF defined
, $IF not defined
and, especially for CompilerVersion
and RTLVersion
.
My versioned PowerShell script List-Delphi-Installed-Packages.ps1 tries to keep an up to date list of versions and features starting with BDS 1 (which was C# Builder) and BDS 2 (which was Delphi 8 with VER160
). One day I will make it Pascal based in stead of BDS based.
The JEDI Code Library has kept a versioned JEDI.INC up to date since Delphi 1.0.
Binding those to specific features can be a tough thing when you depend on version numbers, but less hard when you rely on feature names.
Every couple of years, people start proposing units to replace include files, usually with an argument like this:
If you forget to include it into your source code, all your IFDEFS will fail and in the worst case your workaround won’t be active (the best case is that the compiler runs into an error so you will notice the missing include).
The problem is that for such a unit to work:
- you have to always use it (debunking the above argument)
- you will need to have the very latest version, even if you use old compilers (so you can use code written for any Delphi version)
- See the quoted below “Do you expect that the old versions will get an update to know the new constants RTLVersion_Atlantis = 99.0; too?” below
- you need a central place where that version is available (like
JEDI.INC
)
- it will only work with booleans
- See the quote below “Which is also backwards compatible because the compiler (at least in XE and up, haven’t checked any older versions) just evaluates a non existing value as False.”
- it requires $IF, which is a pain in the ass
- See the quote below “Using
$IF
is a major pita because of $IFEND
or $ENDIF
depending on compiler version and $LEGACYIFEND
setting.”
The only good thing is what Rudy Velthuis commented:
checking for a $DEFINE
like DELPHI_RIO_UP
can go wrong. If you have a typo, it will simply not be recognized as defined and compile the wrong code. Checking for {$IF CompilerVersion >= some_constant}
will fail to compile if some_constant
is not defined
A few people tried:
JEDI.INC
You might think that JEDI.INC was only introduced in 2003, but it is in fact much older as the JEDI Code Library had its own version control system (initially called FreeVCS) before first switching to SVN and later to GIT.
So these are only part of the history:
VER### got introduced as VER40 in Turbo Pascal 4
The product naming mess now completely has disconnected people from binding it to their Delphi version.
It helps knowing that VER### is the compiler version starting with Turbo Pascal 1, and remembering that Delphi 1 had VER80
, and the three digits only started with Delphi 3 which introduced VER100
.
Turbo Pascal 1 through 3 did not have any VER##
defined, despite some sites
The first ever VER##
conditional define was VER40
was introduced in Turbo Pascal 4, as you can see in Full text of “borland :: turbo pascal :: Turbo Pascal Version 4.0 Owners Manual 1987” (or PDF via borland :: turbo pascal :: Turbo Pascal Version 4.0 Owners Manual 1987 : Free Download, Borrow, and Streaming : Internet Archive)
Related:
JEDI History:
–jeroen
Read the rest of this entry »
Like this:
Like Loading...