__attribute__((constructor)) の検証と使用方法まとめ GCCの拡張のため、どこででも動作するわけではないので注意 ソース内に含める場合 #include <stdio.h> __attribute__((constructor)) static void constructor() { puts("constructor"); } __attribute__((destructor)) static void destructor() { puts("destructor"); } int main(int argc, char const* argv[]) { puts("call main"); return 0; }