c++ - Static object lifetime in a shared library with a destructor method -


i have cross-platform dynamic library uses internal static logger object. want able log loading/unloading of library - in windows works quite nice since i'm able log both events when dll_process_attach , dll_process_dettach invocations of dllmain happen. on linux, approach have __attribute__((constructor)) , __attribute__((destructor)) methods same, along these lines:

clog log;  static void __attribute__((constructor)) virtualboxcapturesourceloaded(void) {     log.initialize("/var/log/my-test-log.log");     log("=== start ==="); }  static void __attribute__((destructor)) virtualboxcapturesourceunloaded(void) {     log("=== stop ==="); } 

however, failed since log object destroyed when destructor invoked? question - can control anyhow (compiler flags, attributes destructor, ...) or option use pointer instead of object , destroy manually in destructor?


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -