views:

318

answers:

4

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?

A: 

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.

Steve
+2  A: 

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.

PetriW
You misread the question - Gamecat explicitely mentioned "In the list of directives (**not compiler directives**)
Mihai Limbășan
+2  A: 

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.

François
Codegear confirmed this.
Gamecat
A: 

Codegear has confirmed it is a bug.

Gamecat