title: What are the benefits of a relative path such as "../include/header.h" for a header?
body: <p>I've reviewed questions <a href="https://stackoverflow.com/questions/464560/how-to-use-include-directive-correctly">How to use include directive correctly</a> and <a href="https://stackoverflow.com/questions/179213/c-include-semantics">C++ #include semantics</a> and neither addresses this - nor do the others suggested by SO when I typed the title...</p>
  
  <p>What, if any, are the benefits of writing:</p>
  
  <pre><code>#include "../include/someheader.h"
  #include "../otherdir/another.h"
  </code></pre>
  
  <p>compared with using just a plain file name:</p>
  
  <pre><code>#include "someheader.h"
  #include "another.h"
  </code></pre>
  
  <p>or perhaps a relative name without the '<code>..</code>':</p>
  
  <pre><code>#include "include/someheader.h"
  #include "otherdir/another.h"
  </code></pre>
  
  <p>The problems I see are:</p>
  
  <ul>
  <li>You can't move a header without worrying about which source files include it.</li>
  <li>You can end up with very long paths for headers in dependencies and error reports.  I had one today with "<code>../dir1/include/../../include/../dir2/../include/header.h</code>".</li>
  </ul>
  
  <p>The only merit I can see is that while you do not need to move files around, you might be able to get away without always using '<code>-I</code>' directives to find headers, but the loss of flexibility, and the complexity of compiling in sub-sub-directories, etc seems to outweigh the benefit.</p>
  
  <p>So, am I overlooking a benefit?</p>
  
  <hr>
  
  <p>Thanks for the inputs.  I think the consensus is that there aren't any major benefits to the notation using ".." that I'm overlooking.  In general terms, I like the "somewhere/header.h" notation; I do use it in new projects.  The one I'm working on is anything but new.</p>
  
  <p>One of the problems is that there are various sets of headers, often with a prefix such as <code>rspqr.h</code>, <code>rsabc.h</code>, <code>rsdef.h</code>, <code>rsxyz.h</code>.  These are all related to code in the <code>rsmp</code> directory, but some of the headers are in <code>rsmp</code> and others are in the central include directory, which does not have sub-directories such as <code>rsmp</code> in it.  (And repeat for the various other areas of the code; there are headers in multiple locations, needed randomly by other bits of code.)  Moving stuff around is a major problem because the code has gotten so convoluted over the years.  And the makefiles are not consistent in which <code>-I</code> options are provided.  All in all, it is a sad story of not-so-benign neglect over a period of decades.  Fixing it all without breaking anything is going to be a long, tedious job.</p>