Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-04

zeroing on program startup

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello,

  Just wanted to know if there is some
  FillChar (StaticData, SizeOf (StaticData), 0); in program startup
  procedure exists... Just wanted to get rid of my own FillChar's and
  "v:=0, v:=false" type things in unit initializations. BTW, if this
  "global" FillChar () is implemented then it removes my problems with
  interdependencies. :)

Best regards,
Aleksey

Reply by email

Unknown author
to Aleksey V. Vaneev
Aleksey V. Vaneev wrote 8 lines
Hello, Just wanted to know if there is some FillChar (StaticData, SizeOf (StaticData), 0); in program startup procedure exists... Just wanted to get rid of my own FillChar's and "v:=0, v:=false" type things in unit initializations. BTW, if this "global" FillChar () is implemented then it removes my problems with interdependencies. :)

I think all global variables are zeroed out at program startup.

Michael.

Reply by email

Unknown author
to Aleksey V. Vaneev: Just wanted to know if there is some FillChar (StaticData, SizeOf (StaticData), 0); in…
Aleksey V. Vaneev wrote 8 lines
Hello, Just wanted to know if there is some FillChar (StaticData, SizeOf (StaticData), 0); in program startup procedure exists... Just wanted to get rid of my own FillChar's and "v:=0, v:=false" type things in unit initializations. BTW, if this "global" FillChar () is implemented then it removes my problems with interdependencies. :)

1) All uninitialized global data is always zeroed out at startup, as fas as I know.

2) FPC supports (in Delphi mode) Initialized variables. Declare your variables as

Var
  V : Boolean = False;

this way they are initialized correctly at program startup.

If you don't want to use Delphi mode, you can use

Const
  V : Boolean = False;

Which acts as a initialized variable.

Michael.

Reply by email

Peter Vreman
Show quoted text 8 lines
Hello, Just wanted to know if there is some FillChar (StaticData, SizeOf (StaticData), 0); in program startup procedure exists... Just wanted to get rid of my own FillChar's and "v:=0, v:=false" type things in unit initializations. BTW, if this "global" FillChar () is implemented then it removes my problems with interdependencies. :)

The program loader does zero the BSS section. It's a prerequiste for the compiler else we'll implement it ourselves.

Reply by email