[fpc-pascal] RTFM question (?): which variables/fields are initialized by fpc?
Michael Van Canneyt
michael at freepascal.org
Sun Feb 22 13:06:06 CET 2015
On Sun, 22 Feb 2015, Bart wrote:
> I cannot find it in the docs (probably not looking in the right place).
> Which variables/class-fields are initialized by the compiler?
> My understanding is that:
> - global vars are initialized (zero, false, empty string etc)
> - local vars are not
> But what about class fields?
> Typically I do
> TA = Class
> FInt: Integer;
> FBool: Boolean;
> FString: String;
> FPoint: TPoint;
> constructor TA.Create;
> 1. Is this necessary, and if not, for which types can it be omitted?
> (skip if you know 2)
It is not necessary. When a class is created, it's memory is zeroed out.
> 2. Where is it documented?
Good point. I looked for it, and it is not documented.
I guess this should be added to section 6.1, will do so.
> 3. Does it work the same as in Delphi?
More information about the fpc-pascal