title: How can I perform pre-main initialization in C/C++ with avr-gcc?
body: <p>In order to ensure that some initialization code runs before <code>main</code> (using Arduino/avr-gcc) I have code such as the following:</p>
  
  <pre><code>class Init {
  public:
      Init() { initialize(); }
  };
  
  Init init;
  </code></pre>
  
  <p>Ideally I'd like to be able to simply write:</p>
  
  <pre><code>initialize();
  </code></pre>
  
  <p>but this doesn't compile...</p>
  
  <p>Is there a less verbose way to achieve the same effect?</p>
  
  <p><strong>Note:</strong> the code is part of an Arduino sketch so the <code>main</code> function is automatically generated and cannot be modified (for example to call <code>initialize</code> before any other code).</p>
  
  <p><strong>Update:</strong> ideally the initialization would be performed in the <code>setup</code> function, but in this case there is other code depending on it which occurs before <code>main</code>.</p>