I'm writing a tracing library that is available as a DLL. It is consumed by basically every component in my system. One tricky requirement is that the tracing functions need to be invoked very early in the process lifetime, even before main() runs.
Consumers of this library include executables, statically linked DLLs, delay-loaded DLLs and dynamically loaded DLLs. All the variations.
Some tracing features do no play well with static initialization but others are fine. Ideally, I'd like to be able to offer consumers minimal safe functionality during init time and then full functionality after init is complete.
Asking consumers to make an explicit "I'm done init" call themselves doesn't work because of the fact that certain consumers are DLLs themselves and have no control over the executable hosting them. The same problem just moves one level up the chain.
What I'm hoping is that there is some way for me to ask the runtime whether or I'm currently running in static initialization or whether that stage is complete. Is such a thing possible?
To complicate matters further, I need to run on 5 platforms. I don't need a write-once solution but I do need to get it working somehow on all platforms.