title: How exactly does __attribute__((constructor)) work?
body: <p>It seems pretty clear that it is supposed to set things up.</p>
  
  <ol>
  <li>When exactly does it run?</li>
  <li>Why are there two parentheses?</li>
  <li>Is <code>__attribute__</code> a function? A macro? Syntax?</li>
  <li>Does this work in C? C++?</li>
  <li>Does the function it works with need to be static?</li>
  <li>When does <code>__attribute__((destructor))</code> run?</li>
  </ol>
  
  <p><a href="https://stackoverflow.com/questions/2046426/initialising-a-static-variable-in-objective-c-category/2046997#2046997">Example in Objective-C</a>:</p>
  
  <pre><code>__attribute__((constructor))
  static void initialize_navigationBarImages() {
    navigationBarImages = [[NSMutableDictionary alloc] init];
  }
  
  __attribute__((destructor))
  static void destroy_navigationBarImages() {
    [navigationBarImages release];
  }
  </code></pre>