[英]Compiler directive is not set in Delphi 10.2
I have the following unit implementation in my delphi probject. 我的delphi probject中有以下单元实现。
uses
{$IFDEF Ver270} JSON, {$ELSE} DBXJSON, {$ENDIF}
In Delphi XE4 DBXJSON will be implemented - that's fine. 在Delphi中,XE4将实现DBXJSON - 这很好。 In Delphi XE6 JSON will be implemented - that's fine too. 在Delphi中,XE6将实现JSON - 这也很好。
But in Delphi 10.2, DBXJSON will be implemented - not JSON. 但是在Delphi 10.2中,将实现DBXJSON - 而不是JSON。 Why? 为什么? Is this a bug in Delphi 10.2? 这是Delphi 10.2中的错误吗?
This is not a bug, it is by design. 这不是一个错误,它是设计的。 Each version has exactly one VERXXX
definition. 每个版本都只有一个VERXXX
定义。 VER270
is defined in XE6 and XE6 only. VER270
仅在XE6和XE6中定义。 For version 10.2 VER320
is defined. 对于版本10.2,定义了VER320
。
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
. 另一种选择是使用像jedi.inc
这样的标准包含文件。 This takes the pain out of such conditional statements. 这会消除这些条件陈述的痛苦。 If you use jedi.inc
then you can code it like this: 如果您使用jedi.inc
那么您可以像这样编码:
uses
{$IFDEF DELPHIXE6_UP} JSON, {$ELSE} DBXJSON, {$ENDIF}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.