Removing Unused (Unreferenced) Static Global Variable Constants in C++
<p><strong>Update</strong>,</p>

<p>I tried removing the static modifier, and I tried putting them in a namespace (as well as both of those), and none worked.
<br /><br /><br />
Hi,</p>

<p>I have a header file with common constants like names and stuff that are automatically included in each project (an example follows). The thing is that they are included in the compiled binary (EXE) whether they are used (referenced) or not. If I use DEFINEs instead, then naturally they are not included if they are not used, but of course consts are better than defines so… I tried Googling it, but the closest thing I could find was <a href="http://stackoverflow.com/questions/1229430/how-do-i-prevent-my-unused-global-variables-being-compiled-out">a question</a> right here on SO that did not quite help. Matters of i18n aside, how can I keep the ones that are not used out of the binary, while still keeping it easy to use like this?</p>

<p>Thanks.
<br /><br /><br /></p>

<pre><code>//COMMON.H:
  static const CString s_Company _T("Acme inc.");
  //etc. others
  static const CString s_Digits  _T("0123456789");

//TEST.CPP:
  #include common.h
  int main() {
    AfxMessageBox(s_Company);
  }

  //s_Company should be in the final EXE, but s_Digits should not be, but is
</code></pre>
