You're 100% correct. In non-delphi modes you have to always explicitly dereference pointer.Originally Posted by Srki_82
Why ? The long story is, AFAIK: Because in non-delphi modes you get other feature: Assuming that PMyType is a pointer to TMyType, and you have variable like MyTypePtr (of type PMyType), you can write things like
MyTypePtr[100]
and it will be treated like MyTypePtr was a pointer to an array of TMyType structures. In Delphi (or in FPC in delphi mode) to do the same thing you would have to declare some dummy type that is a pointer to an "inifite" array, like
TMyTypeArray = array[0..MaxInt div SizeOf(TMyType)-1]of TMyType;
PTMyTypeArray = ^TTMyTypeArray;
and write
PTMyTypeArray(MyTypePtr)[100]
So in Delphi mode you get automatic dereferencing of pointers to arrays/records, and in non-delphi mode you get treating pointers as arrays (like in C). These two features together could in some cases produce ambiguous code, so you can get only one feature or the other, not both at once...
Most probably you're accidentaly compiling your unit in delphi mode, and program file in non-delphi (like objfpc) mode. Maybe you include in your unit some file that does {$mode delphi} ? To hunt this down you can compile your code with -vc option ("Show conditionals"), look there for messages likeOriginally Posted by WILL
Macro defined: FPC_DELPHI
or
Macro defined: FPC_OBJFPC
These indicate FPC $mode changes.
Bookmarks