如何转义 Free-Pascal 中的保留字?
实际上我正在努力将一些库翻译成 free-pascal。所以问题是在delphi中可以使用&符号来转义保留字,但在free-pascal中不起作用。编译器抱怨此消息
非法字符“'&'”($26)
ForLibDx.pas(72,13) 致命:包含与符号时
。实际上我正在使用 {$MODE DELPHI}
在 free-pascal
FPC 2.2.4
Lazarus 0.9.28.2
下编译我的单元,提前致谢。
Actually i'am working on translate some librarys to free-pascal. so the problem is which in delphi can use the ampersand (&) symbol to escape a reserved word, but in free-pascal does not work. the compiler complains with this messageForLibDx.pas(72,13) Fatal: illegal character "'&'" ($26)
when include an ampersand symbol.
actually i am using the {$MODE DELPHI}
to compile my units under free-pascal
FPC 2.2.4
Lazarus 0.9.28.2
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我回忆,FPC 编译器没有转义保留字的方法。
作为转义字符以转义保留字的与号 (&) 是 Delphi 语言的 Delphi 编译器独有的功能。
您可以通过使用完全限定名称(包括单元和类名)来解决此问题,如 Rob Kennedy 建议的 此处。
注意:建议在 Delphi 中对于非生成的代码避免使用这些 & 符号转义,因为并非所有 IDE 和第 3 方工具都可以处理它。
——杰罗恩
From what I recollect, the FPC compiler does not have a means for escaping reserved words.
The ampersand (&) as an escape character to escape reserved words is a Delphi-compiler-only feature of the Delphi language.
You might work around this by using the fully qualified name (including unit, and classname) as Rob Kennedy suggests here.
NB: It is recommended to avoid these ampersand escapes in Delphi for non-generated code, as not all of the IDE and 3rd party tools can cope with it.
--jeroen