(e-mail address removed) (Manuel) wrote in @posting.google.com:
Can I invoke a function before main
I could do it by invoking it in a Global object's constructor .
Is there any other method other than this.
Individual implementations may have extensions to do it. However, from a
strictly C++ standpoint, all you can do is rely on a global object's
constructor. However one thing to keep in mine is what the order of global
object constructors is.... within a single translation unit (generally
speaking, 1 .cpp file plus everything it includes) global objects are
constructed in the order that they are declared. The twist is that
_between_ translation units, it is undefined as to what order the
translation units are constructed in. So if you have two translation
units, with two global objects each (say A1, A2, B1, and B2), the order of
construction could be either A1 - A2 - B1 - B2, or B1 - B2 - A1 - A2. It's
up to the compiler to make that decision.