Re: [fpc-pascal] Is there a way to execute code after 'initialization' and before 'main', i. e. AddExitProc complement?
On 28 Nov 2017 9:04 PM, "Роман via fpc-pascal" < fpc-pascal@lists.freepascal.org> wrote: > Can I run SortAndInitialize before 'main' without additional user actions? Maybe not exactly what you want but you could probably add the SortAndInitialize procedure to the initialization section of a new unit and add this unit as the last unit to your program. This use case is probably a good candidate for using the "section" modifier to specify initialization sequence. Unfortunately not available in the compiler for code sections AFAIK. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is there a way to execute code after 'initialization' and before 'main', i. e. AddExitProc complement?
Am 28.11.2017 20:04 schrieb "Роман via fpc-pascal" < fpc-pascal@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 order. 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? No, you can't. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Is there a way to execute code after 'initialization' and before 'main', i. e. AddExitProc complement?
'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? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal