title: How do I use the C preprocessor to make a substitution with an environment variable
body: <p>In the code below, I would like the value of <code>THE_VERSION_STRING</code> to be taken from the value of the environment variable <code>MY_VERSION</code> at compile time</p>
  
  <pre><code>namespace myPluginStrings {
  const  char* pluginVendor = "me";
  const  char* pluginRequires =  THE_VERSION_STRING;
  };
  </code></pre>
  
  <p>So that if I type:</p>
  
  <pre><code>export MY_VERSION="2010.4"
  </code></pre>
  
  <p><code>pluginRequires</code> will be set at "2010.4", even if <code>MY_VERSION</code> is set to something else at run time.</p>
  
  <p><strong>UPDATE:</strong> (feb 21) Thanks for your help everyone. It works.
  As I'm using Rake as a build system, each of my CFLAGS is a ruby variable. Also the values need to end up in quotes. Therefore the gcc command line for me needs to look like this:</p>
  
  <pre><code>gcc file.c -o file -D"PLUGIN_VERSION=\"6.5\"" 
  </code></pre>
  
  <p>Which means this is in my Rakefile:</p>
  
  <pre><code>"-D\"PLUGIN_VERSION=\\\"#{ENV['MY_VERSION']}\\\"\""
  </code></pre>