Delphi 和pointermath(文档中可能存在错误)
我正在浏览 Delphi 2009 语言指南。 并且发现了一些奇怪的事情。 在指令列表(不是编译器指令)中,我找到了pointermath。
RAD-Studio
Reference
Delphi Reference
Delphi Language Guide
Fundamental Syntactic Elements
Fundamental Syntactic Elements
[Directives]
我知道这是一个编译器指令 {$POINTERMATH ON|OFF} 但我不知道如何使用这个家伙。 帮助中没有附加信息,所以我尝试了一些东西,但没有成功。
procedure Name; pointermath; // gave an error
所以有几种可能:
- 还没有实现。
- 这是帮助中的一个错误。
- 我还没有找到合适的地方来使用它。
我认为这是一个错误,(还有更多的seled必须密封)。
有人知道这个指令吗?
I was browsing the Delphi 2009 language guide. And found something strange. In the list of directives (not compiler directives) I found pointermath.
RAD-Studio
Reference
Delphi Reference
Delphi Language Guide
Fundamental Syntactic Elements
Fundamental Syntactic Elements
[Directives]
I know it is a compiler directive {$POINTERMATH ON|OFF} but I did not know how to use this guy. There is no additional information in the Help so I tried a little something but without success.
procedure Name; pointermath; // gave an error
So there are several possibilities:
- it is not yet implemented.
- it is a bug in the help.
- I have not found the right place to use it yet.
I assume it is a bug, (there are more seled must be sealed).
Does anybody know anything about this directive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
除非 Barry Kelly 证明我们错了(他是这方面的权威),否则我会投票支持文档错误:它适用于“编译器指令”章节。
Unless Barry Kelly proves us wrong (he is the authority on that), I would vote for a documentation bug: it was meant for the 'compiler directives' chapter.
Pointermath 可以让你做这样的事情:
如果没有 Pointermath,你会得到:
[DCC 错误] unit.pas(135): E2015 运算符不适用于此操作数类型
从本质上讲,这意味着您不再需要将指针类型转换为 Integer 来将它们递增一个数值。
Pointermath lets you do stuff like this:
Without pointermath on you get:
[DCC Error] unit.pas(135): E2015 Operator not applicable to this operand type
In essence this means you no longer have to typecast pointers to Integer to increment them by a numerical value.
Codegear 已确认这是一个错误。
Codegear has confirmed it is a bug.
我认为这意味着它允许你像指针数学一样做 C 语言。 直到 Delphi 2009,您只能对类型化指针进行有限的指针数学运算。
I think what it means is it allows you to do C like pointer maths. Up to Delphi 2009, you could only do limited pointer maths on typed pointers.