如何在编译时检测特定的 RTL 功能?
为了举例,让我们检查一下臭名昭著的 TStrings.StrictDelimiter
:
{$IF Declared(TStrings.StrictDelimiter)}
{$MESSAGE WARN 'Beware of TStrings.StrictDelimiter which is False by default!'}
{$IFEND}
但是,Declared
编译器内部报告条件行上的语法错误:E2029 ')' Expected but '.'找到了。 (在XE上测试)
For sake of example lets check for infamous TStrings.StrictDelimiter
:
{$IF Declared(TStrings.StrictDelimiter)}
{$MESSAGE WARN 'Beware of TStrings.StrictDelimiter which is False by default!'}
{$IFEND}
However, Declared
compiler intrinsic reports syntax error on conditional line: E2029 ')' expected but '.' found
. (tested on XE)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于Delphi XE2,我使用这个:
换句话说:我测试自任何特定delphi版本以来引入的符号是否存在。相同的构造可用于设置变量或常量或编译器定义,因此进一步的代码可以使用它们。
注意:我为过去几年安装的所有 Delphi 版本的
Source
文件夹保留了备份。通过像 BeyondCompare 这样的工具放置这些文件夹并浏览差异文件,很快就会给你一些可以测试的符号......For Delphi XE2 I'm using this :
In other words : I test for the existence of symbols that are introduced since any particular delphi-version. The same construct can be used to set a variable or constant or compiler define, so further code can use these instead.
Note : I keep a backup around of the
Source
folder for all Delphi versions that I've had installed in the past few years. Putting these folders through a tool like BeyondCompare and browsing through the differencing files, will quickly give you a few symbols that you can test for....不幸的是,不支持这种表达式,您必须知道在哪个 RTL/编译器版本中引入了某些功能,然后使用 预定义条件符号,例如
VER
、RTLVersion
、编译器版本等。Unfortunately this kind of expressions aren't supported, you have to know in which RTL / compiler version some feature was introduced and then use predefined conditional symbols like
VER<nnn>
,RTLVersion
, CompilerVersion etc.