I would like to add some class operators to a record, but I still want to code to compile under older Delphi versions.
What define should I use so that the operator will compile in all versions that support it, but will be ignored in older Delphi versions.
type
Iso8601 = {$ifndef UNICODE}object{$else}record{$endif}
data: Integer;
{$ifdef ????} <-- what to put here
class operator Add(A: Iso8601): Iso8601;
{$endif}
end;
I know that records with member functions coincide with the Unicode update, but what define do I use for the class operators?
As TLama said: They were introduced in Delphi 2006, so {$IF CompilerVersion >= 18}.
Also, see http://docwiki.embarcadero.com/RADStudio/XE6/en/Compiler_Versions
and see ulrichb's answer at Complete list of defines for Delphi versions about the file in Jedi.inc. It's what I use to work with different code for different compiler versions
Edit: I also like https://github.com/project-jedi/jedi/blob/master/jedi.inc because it has separate defines per language feature, e.g. SUPPORTS_CLASS_OPERATORS that you requested.
Also the "UP" defines, so e.g. DELPHIXE2_UP will be true also in XE3, XE4, 5, 6 etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With