C++ static initialization vs __attribute__((constructor))
foo will be printed first, as the objects are initialized in the order of their declarations. Run and see: Ideone online demo By the way, __attribute__((constructor)) is not Standard C++. It is GCC’s extension. So the behavior of your program depends on how GCC has defined it. In short, it is implementation-defined, according to it … Read more