title: prevent gcc from removing an unused variable
body: <p>In our source files we usually have a version string like that:</p>
  
  <pre class="lang-c prettyprint-override"><code>static const char srcvers[] = "VERSION/foo.c/1.01/09.04.15";
  </code></pre>
  
  <p>When that string isn't optimized away, it's quite useful in certain cases, as one can determine the version of each source file linked to an executable by simply calling <code>strings a.out | grep VERSION</code>.</p>
  
  <p>Unfortunately it <strong>is</strong> optimized away by gcc (using '-O'). So my question is, is there a simple way (a compiler switch would be great) to make gcc keep that variable (its name is always the same) without switching off any other optimizations.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>What, in my opinion, makes the question different from <a href="https://stackoverflow.com/questions/7083482/how-to-prevent-compiler-optimization-on-a-small-piece-of-code">that one</a>, is that I'm was hoping to find a solution for which I wouldn't have to touch thousands of source files.  </p>