On Sun, Oct 4, 2015 at 8:27 AM, Daniel Kochmański daniel@turtleware.eu wrote:
It *is* possible to strictly control initialization order while using linker functions: either ensure that you link objects in the correct order (duh), and/or have your ensure_foo_initialized functions explicitly call each other.
How will it be different from the current approach (except introducing some compiler dependnet extensions)?
In our day and age, all compilers and linkers support that out of the box.
Is there any clear benefit from using such constructors over the current approach[1] (except the pride of using modern approach)?
[1] Given it is bugfree(tm)
Indeed, your approach may be better, especially if the "random number" (which I hope is instead based on the sha256sum of the source and its dependencies) allows overlaying multiple versions of the code without clashes.
On the other hand, if you want to be more directly integrated with the C toolchain, it makes sense to use the C toolchain as intended.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org When your hammer is C++, everything begins to look like a thumb. — Steve Hoflich on comp.lang.c++