When exactly is a function used to initialize a global variable executed?
<p>At the top of some file in my program, outside all functions, I have these variables:</p>

<pre><code>namespace {
  int foo = foo_func();
}

int bar = bar_func();
</code></pre>

<p>As you know, <code>foo</code> is a variable local only to that file, but <code>bar</code> is accessible to every file.</p>

<p>...but question: When are the functions <code>foo_func()</code> and <code>bar_func()</code> actually run? Does this happen before <code>main()</code> runs, or possibly sometime later (say just before those values are actually needed)?</p>
