https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108183
--- Comment #14 from Iain Sandoe <iains at gcc dot gnu.org> --- coming back to this code: === extern "C" void _M2_termios_init (int, char *[], char *[]) { } extern "C" void _M2_termios_fini (int, char *[], char *[]) { } extern "C" void _M2_termios_dep (void) { } struct _M2_termios_ctor { _M2_termios_ctor (); } _M2_termios_ctor; _M2_termios_ctor::_M2_termios_ctor (void) { // M2RTS_RegisterModule ("termios", _M2_termios_init, _M2_termios_fini, // _M2_termios_dep); } ==== I think this is not currently doing what is expected (it's certainly inconsistent with the compiler's PoV .. from my debugging). ---- The declaration in the compiler thinks that _M2_termios_ctor is the symbol for a function. Where (because of the way this shim is written) it's actually the name of a static variable. Which means if it was ever called "boom". However, my current understanding us that M2_link() is just a mechanism to ensure that all the library code is pulled in (so perhaps it would never be called). Actually, that should not be necessary if the decls are correctly marked as "used". Furthermore, the initialisation code for the static instance will be entered automatically into the startup (so it's out of your control). ===== What about, instead: extern "C" void _M2_termios_init (int, char *[], char *[]) { } extern "C" void _M2_termios_fini (int, char *[], char *[]) { } extern "C" void _M2_termios_dep (void) { } extern "C" void _M2_termios_ctor (void) { M2RTS_RegisterModule ("termios", _M2_termios_init, _M2_termios_fini, _M2_termios_dep); } == now the symbol will indeed refer to the CTOR that causes the module to be registered. As it is written that CTOR will not be called unless you do it. IFF you want it to be called "automatically" at program startup .. you can mark it __attribute__((constructor))