Re:Some obscure C features
by epilk on Thursday January 25, 2018 @05:57PM
(#16235534)
I also encountered the last problem, it can be handled pretty easily with __attribute__((constructor)):
[ Parent
| on HN ]
A quite fun, related feature of the AIX linker, is that it will automatically make any function name prefixed with "__sinit_" statically invoked the same as this attribute does. So you name the function a certain way to take care of AIX/xlc, add pragmas to take care of other UNIX vendor compilers add the attribute for any GCC-based (or compatible) compiler, and they are actually pretty cross-platform! Not... that... I would use these all the time or anything like that :)
The fun was even better in the old days, where each UNIX had a different concept of what a shared object should be.
AIX used to implement shared objects just like on Windows, using an export definitions file and import libraries, for example.
Still does to this day. And it has a machine-wide cache of libraries, so simply updating the library and restarting the processes isn't enough to get the new version -- you have to be aware it could be in the cache and might need to be manually flushed by someone with elevated access. shudder