title: Can you use environment variables in C/C++ include directives?
body: <p>Say I have a folder layout as such:</p>
  
  <pre><code>.
  +-- Project
      +-- src
          +-- foo.h
          +-- foo.cpp
      +-- test
          +-- test_foo.c
  </code></pre>
  
  <p>And <code>test_foo.c</code> looks as such:</p>
  
  <pre><code>#include "../src/foo.h"
  #include &lt;stdio.h&gt;
  #include &lt;assert.h&gt;
  
  int main() {
      assert(foo() == true);
      printf("Test complete");
      return 0;
  }
  </code></pre>
  
  <p>Is there a way to replace the line <code>#include "../src/foo.h"</code> with a variable that points to the source directory?  For instance, say in my environment I have a have a variable:</p>
  
  <pre><code>PROJECT_SRC="./Project/src/"
  </code></pre>
  
  <p>And then I could have the include directive as such:</p>
  
  <pre><code>#include "PROJECT_SRC/foo.h"
  </code></pre>
  
  <p>This would be nice as I could then have a bash script that exports all the paths I need for a certain project.  Also, if the file is included in different test and build files I would have to set up the relative path for each (although not much work) which would be less robust than one absolute path.</p>
  
  <p>An alternative might be a tool like <a href="http://www.cmake.org/" rel="nofollow"><code>CMake</code></a> that can do this. Or is this considered bad practice?</p>