Neither woodbrian nor Flibble wrote if it is good or bad idea.
Flibble seemingly wrote that it is possible and woodbrian
seemingly wrote that it has messy style. IMHO it is an idea
to avoid.
Calling order of such static object (and static data member
object) constructors is defined only within single compilation
unit that defines those. In project that matters there are lot of
compilation units. So when the statics are defined in several
compilation units and the initialization order matters then
things will become quite hairy.
The reasons how that order matters may pop up in late stages
of development and the "best" idioms of dealing with such
fiasco (like Schwarz counter) look quite confusing and will
result with pointless code generated. Additionally such
statics are source of synchronization issues and later there
can be destruction order fiasco as well. ;)
So I typically try to avoid the statics. When these are
unavoidable then I try to make these with maximally
lightweight and independent construction. When more
sophisticated initialization is needed then I try to dodge
it by adding lazy or explicit additional initialization steps
that will run after 'main' is called.
>
> And in a freestanding environment, the toolchain can happily have no
> main() function (the "main" function can have any name), and you may
> have many methods for calling code before a "main" function is run.
C++ standard has seemingly no good policy for choosing
what belongs into freestanding library and what does not.
It seems to require more than needed; also there are no
mechanism of indicating optional features. As result what
is "freestanding" feels incomplete and inconsistent. In
practice it is some non-conforming slice of C++ and so
it is hard to build any arguments upon it.