user7421317
user7421317

Reputation:

Compiler directive is not set in Delphi 10.2

I have the following unit implementation in my delphi probject.

uses
{$IFDEF Ver270} JSON, {$ELSE} DBXJSON, {$ENDIF}

In Delphi XE4 DBXJSON will be implemented - that's fine. In Delphi XE6 JSON will be implemented - that's fine too.

But in Delphi 10.2, DBXJSON will be implemented - not JSON. Why? Is this a bug in Delphi 10.2?

Upvotes: 2

Views: 206

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

This is not a bug, it is by design. Each version has exactly one VERXXX definition. VER270 is defined in XE6 and XE6 only. For version 10.2 VER320 is defined.

In your scenario it is much simpler to use code like this:

uses
  {$IF RTLVersion >= 27} JSON, {$ELSE} DBXJSON, {$IFEND}

Another option is to use a standard include file like jedi.inc. This takes the pain out of such conditional statements. If you use jedi.inc then you can code it like this:

uses
  {$IFDEF DELPHIXE6_UP} JSON, {$ELSE} DBXJSON, {$ENDIF}

Upvotes: 8

Related Questions