[fpc-pascal] Pointers
Jonas Maebe
jonas.maebe at elis.ugent.be
Thu Feb 11 21:07:17 CET 2010
On 11 Feb 2010, at 18:17, Rainer Stratmann wrote:
> In the past with the turbopascal compiler and other always sizeof
> byte was
> added.
That is not true. This program prints "2" when compiled under Turbo
Pascal:
{$t-}
type
pw = ^word;
var
w: pw;
begin
w:=nil;
inc(w);
writeln(longint(w));
end.
(and the result does not depend on {$t+} or {$t-}; that only
influences whether e.g. @wordvar has the type "^word" or plain
"pointer").
Furthermore, Turbo Pascal did not support performing pointer
arithmetic using anything else but inc() and dec() (so things like
"ppp := ppp + http.header_anz" or "w:=w+1" would not compile under
TP), except for pchar variables (in which case the base value is
sizeof(char), since that's what a pchar points to).
Jonas
More information about the fpc-pascal
mailing list