[fpc-pascal] Is there a way to execute code after 'initialization' and before 'main', i. e. AddExitProc complement?

Роман runewalsh at inbox.ru
Sun Nov 26 18:21:35 CET 2017


'Initialization' sections are executed in poorly predictable order, so I 
want to partially order them according to some form of explicit 
prioritization and execute before control flow enters main block (so I 
won't need to run all that initialization by hand, neither I would be 
able to forget to do that). Like:

unit UnitA;
...
procedure Init;

initialization
   RegisterUnit('UnitA', @Init);
end;

unit UnitB;
...
procedure Init;

initialization
   RegisterUnit('UnitB', @Init, {priority} +1);
end;

...
procedure SortAndInitialize;
...

Can I run SortAndInitialize before 'main' without additional user actions?



More information about the fpc-pascal mailing list