2016-02-17 15:16 GMT-02:00 Jonas Maebe <jonas.ma...@elis.ugent.be>:

> Jonas Maebe wrote:
>
>> 3 - When i declare a pointer as a global variable or as a member of a
>>> record, can i assume that its initial value is nil?
>>>
>>
>> No.
>>
>
> Correction: all global variables are always zeroed, so that includes
> pointers, records and hence also pointers in records (if those records
> themselves are global variables). Pointers, records or record fields in are
> not zeroed because they are pointers/records/record fields though (so not
> in case they are local variables).


Just to clarify: if i have a record type with a pointer field, this field
will always zeroed?

e.g

type
   TMyRecord = record
   private
     FMyPointer: Pointer;
   public
     property MyPointer: Pointer read FMyPointer;
   end;

......

procedure ShowMyPointerValue;
var
  MyRecord: TMyRecord;
begin
  writeln('My pointer value: ' + IntToStr(Integer(MyRecord.MyPointer)));
end;

end.


is correct to say that the above code will always print 'My pointer value:
0'?

Regards
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to