I'm writing a C++ component that brings some requirements and after intense web browsing I did no find any clue...

  1. How to make some pieces of code called before main() and also static constructors?
  2. How to make some pieces of code called after main() and also static destructors?
  3. How to ensure that this hack is portable?

Thanks in advance for your help.