1

How do you (compile-time) detect the difference between Alexandria 11.2 and 11.3 (or, rather, how do you detect you are at 11.3 or later?)

Both have CompilerVersion and RTLVersion value at 35.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
HeartWare
  • 7,464
  • 2
  • 26
  • 30
  • 1
    Please do not add answers to the question body itself. Instead, you should add it as an answer. [Answering your own question is allowed and even encouraged](https://stackoverflow.com/help/self-answer). – Adriaan Mar 07 '23 at 10:39

2 Answers2

6

There are constants RTLVersion111, RTLVersion112 and RTLVersion113 declared depending on the version you are compiling with. These can be detected like this:

{$IF declared(RTLVersion113)}
  ...
{$IFEND}
HeartWare
  • 7,464
  • 2
  • 26
  • 30
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
  • Thank you - I have added a more elaborate answer based on your info, but you still get the points for leading me there :-). Alexandria3 should be defined using my extended answer if you are at least on v11.3 – HeartWare Mar 07 '23 at 10:39
0

Extended Answer, based on Uwe Raabe's answer:

{$IF CompilerVersion > 35 }
  {$DEFINE Alexandria3 }
{$ELSEIF CompilerVersion < 35 }
  {$UNDEF Alexandria3 }
{$ELSEIF Declared(RTLVersion113) }
  {$DEFINE Alexandria3 }
{$ELSE }
  {$UNDEF Alexandria3 }
{$ENDIF }

Now you can

{$IFDEF Alexandria3 }

to conditionally compile code for Alexandria3 or later.

HeartWare
  • 7,464
  • 2
  • 26
  • 30
  • Likely because it is more of a "what I did with the answer" comment than an answer to the question. (I did not downvote). – Brian Mar 07 '23 at 16:20
  • I would use a single `{$IF}` like this: `{$IF (CompilerVersion > 35) OR ((CompilerVersion = 35) AND Declared(RTLVersion113)) } {$DEFINE Alexandria3} {$ELSE} {$UNDEF Alexandria3} {$IFEND}` – Remy Lebeau Mar 07 '23 at 16:36
  • @brian Actually, it answers the question precisely (which the accepted answer does not): "how do you detect 11.3 OR LATER?"... (and who deleted my initial question?) – HeartWare Mar 08 '23 at 18:41