title: const variables in header file and static initialization fiasco
body: <p>After reading a lot of the questions regarding initialization of static variables I am still not sure how this applies to <code>const</code> variables at namespace level.</p>
  
  <p>I have kind of the following code in a <em>header</em> file <code>config.h</code> generated by the build script:</p>
  
  <pre><code>static const std::string path1 = "/xyz/abc";
  static const std::string path2 = "/etc";
  </code></pre>
  
  <p>According to what I have read the <code>static</code> keyword is not necessary, even deprecated here.</p>
  
  <p><em>My Question:</em> Is the code above prone to the static initialization fiasco?</p>
  
  <p>If I have the following in a <em>header</em> file <code>myclass.h</code>:</p>
  
  <pre><code>class MyClass
  {
  public:
      MyClass(const std::string&amp; str) : m_str(str) {}
      std::string Get() const { return m_str; }
  
  private:
      std::string m_str;
  }
  
  const MyClass myclass1("test");
  </code></pre>
  
  <p>Will this pose any problems with static initialization?</p>
  
  <p>If I understood right, due to <code>const</code> variables having internal linkage there should be no problem in both cases?</p>
  
  <p><strong>Edit:</strong> (due to dribeas answer)</p>
  
  <p>Maybe I should mention that I am interested in use cases like:</p>
  
  <p>In <code>main.cpp</code>:</p>
  
  <pre><code>#include &lt;config.h&gt;
  #include &lt;myclass.h&gt;
  
  std::string anotherString(path1 + myclass1.Get());
  
  int main()
  {
      ...
  }
  </code></pre>
  
  <p>Another question regarding this use case: Will the compiler optimize away <code>path2</code> in this case?</p>