如何转义 Free-Pascal 中的保留字?

发布于 2024-10-08 19:13:16 字数 298 浏览 0 评论 0原文

实际上我正在努力将一些库翻译成 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 message
ForLibDx.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开雨落又逢春i 2024-10-15 19:13:16

据我回忆,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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文