Recent

Author Topic: [Solved] Initialization sequence of Units, Linux/Windows  (Read 626 times)

petevick

  • Sr. Member
  • ****
  • Posts: 347
[Solved] Initialization sequence of Units, Linux/Windows
« on: February 02, 2023, 08:26:03 am »
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??
« Last Edit: February 04, 2023, 12:21:11 pm by petevick »
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

TRon

  • Hero Member
  • *****
  • Posts: 2515
Re: Initialization sequence of Units, Linux/Windows
« Reply #1 on: February 02, 2023, 08:45:07 am »
Perhaps the following link is able to help you out ?
https://wiki.freepascal.org/Event_order

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2069
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Initialization sequence of Units, Linux/Windows
« Reply #2 on: February 02, 2023, 08:53:50 am »
You can easy find out on your own:
Code: Pascal  [Select][+][-]
  1. unit UnitX;
  2. interface
  3. implementation
  4.  
  5. initialization
  6. // ShowMessage('UnitX Initialized!');
  7. // WriteLn('UnitX Initialized');
  8.  
  9. end.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Initialization sequence of Units, Linux/Windows
« Reply #3 on: February 02, 2023, 08:58:01 am »
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??
There is no difference between windows and linux.
And initialization is *before* FormActivate not in FormActivate.
Activation is after newinstance (allocation) and subsequently initinstance (initialization) is called.
Whole units are usually initialized left to right if they actually need to be initialized, that is..
« Last Edit: February 02, 2023, 09:01:50 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: Initialization sequence of Units, Linux/Windows
« Reply #4 on: February 02, 2023, 09:08:38 pm »
I have a project that I compile in Linux and Windows, this project has several Units, let's call them Unit2 and Unit3. In Linux I know that in the TForm1.FormActivate procedure, Unit2 and 3 have been initialized, which seems reasonable, but they haven't been initialized in Windows at that point, so at what point would these Unit2 and 3 get initialized in Windows ??

How do you assume that these units haven't been “initialized”?

petevick

  • Sr. Member
  • ****
  • Posts: 347
Re: Initialization sequence of Units, Linux/Windows
« Reply #5 on: February 04, 2023, 12:20:48 pm »
This is has been doing my head in, I've obviously changed something as I'm not getting the error that originally prompted me to make this topic. So unfortunately I now can't replicate whatever was causing the problem  %) I'll mark as solved and move on along  :-[
Pete Vickerstaff
Linux Mint 21.2 Cinnamon, Windows 10, Lazarus 3.2, FPC 3.2.2

 

TinyPortal © 2005-2018