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

Sven Barth pascaldragon at googlemail.com
Tue Nov 28 23:32:36 CET 2017

Am 28.11.2017 20:04 schrieb "Роман via fpc-pascal" <
fpc-pascal at lists.freepascal.org>:

'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).

If unit A uses unit B in the interface section then unit B's initialization
section is always run before A's. For the implementation section the same
holds true if there isn't a cycle otherwise it depends on the unit load


unit UnitA;
procedure Init;

  RegisterUnit('UnitA', @Init);

unit UnitB;
procedure Init;

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

procedure SortAndInitialize;

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

No, you can't.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171128/0dcead52/attachment.html>

More information about the fpc-pascal mailing list