Delphi 和pointermath(文档中可能存在错误)

发布于 2024-07-11 19:44:29 字数 638 浏览 3 评论 0原文

我正在浏览 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 技术交流群。

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

发布评论

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

评论(4

灼疼热情 2024-07-18 19:44:29

除非 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.

蒗幽 2024-07-18 19:44:29

Pointermath 可以让你做这样的事情:

{$POINTERMATH ON}
procedure Test;
var
  temp: PWord;
begin
  temp := anAddress;
  temp := temp + 16;
  // temp now points to anAddress+$20 (2*16)
end;

如果没有 Pointermath,你会得到:
[DCC 错误] unit.pas(135): E2015 运算符不适用于此操作数类型

从本质上讲,这意味着您不再需要将指针类型转换为 Integer 来将它们递增一个数值。

Pointermath lets you do stuff like this:

{$POINTERMATH ON}
procedure Test;
var
  temp: PWord;
begin
  temp := anAddress;
  temp := temp + 16;
  // temp now points to anAddress+$20 (2*16)
end;

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.

作业与我同在 2024-07-18 19:44:29

Codegear 已确认这是一个错误。

Codegear has confirmed it is a bug.

奢望 2024-07-18 19:44:29

我认为这意味着它允许你像指针数学一样做 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.

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