How exactly does __attribute__((constructor)) work?
It runs when a shared library is loaded, typically during program startup. That’s how all GCC attributes are; presumably to distinguish them from function calls. GCC-specific syntax. Yes, this works in C and C++. No, the function does not need to be static. The destructor runs when the shared library is unloaded, typically at program … Read more