title: C++ static initialization vs __attribute__((constructor))
body: <p>Example:</p>
  
  <pre><code>struct Foo { Foo() { printf("foo\n"); } };
  static Foo foo;
  
  __attribute__((constructor)) static void _bar() { printf("bar\n"); }
  </code></pre>
  
  <p>Is it deterministic wether <code>foo</code> or <code>bar</code> is printed first?</p>
  
  <p>(I hope and would expect that constructors of static objects are always executed first but not sure and GCCs doc about the constructor attribute doesn't say anything about it.)</p>