Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What ifdef should I use to check for class operators

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?

like image 619
Johan Avatar asked Feb 02 '26 23:02

Johan


1 Answers

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

like image 196
Reversed Engineer Avatar answered Feb 05 '26 12:02

Reversed Engineer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!