[fpc-pascal] Class constructor called unconditionally

silvioprog silvioprog at gmail.com
Thu Mar 31 16:58:00 CEST 2016


On Thu, Mar 31, 2016 at 11:28 AM, Michael Van Canneyt <
michael at freepascal.org> wrote:
[...]

> I suspect the problem is not in the mode, but in detecting whether a class
> is used
> or not in a program. It becomes very complicated when you use e.g.
> run-time packages.
>

Hm... so FPC class constructor (or class initialization) works like unit
initialization.


> Delphi itself is buggy in this regard, and has been since at least D7.
> For this reason, in general I advise against extensive use of
> initialization sections etc...


Thanks for sharing this information.

It's hard to make test-case when the code has an extensive use of
initialization sections, so currently I'm avoiding it too. However, I need
to register some classes in a class list, so I'm changing my code to do it
in some place like application initialization.

--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160331/b421468d/attachment.html>


More information about the fpc-pascal mailing list