I reviewed the issues of using the include directive and C ++ #include semantics correctly , and none of the addresses are the others suggested by SO when I typed in the name ...
What, if any, are the advantages of writing:
#include "../include/someheader.h" #include "../otherdir/another.h"
compared to using a simple file name:
#include "someheader.h" #include "another.h"
or possibly a relative name without ' .. ':
#include "include/someheader.h" #include "otherdir/another.h"
I see the following problems:
- You cannot move the header without worrying about which source files include it.
- You can get very long paths for headers in dependencies and bug reports. Today I had "
../dir1/include/../../include/../dir2/../include/header.h ".
The only thing I see is that although you do not need to move files, you can leave, not always using the โ -I โ directives to search for headers, but the loss of flexibility and the complexity of compilation in sub-directories, etc., seems to outweigh the benefits.
So, I do not see the benefits?
Thanks for the input. I think the consensus is that there are no significant benefits to the notation using ".." which I skip. In general, I like the notation "somewhere / header.h"; I use it in new projects. The one I'm working on is nothing short of new.
One of the problems is that there are different groups of headers, often with a prefix, such as rspqr.h , rsabc.h , rsdef.h , rsxyz.h . They are all related to the code in the rsmp directory, but some headers are in rsmp , while others are in the central include directory, which does not have subdirectories such as rsmp . (And repeat for various other areas of the code, there are headers in several places that need to be randomly executed using other bits of code.) Moving material around is a serious problem because the code has become so confusing over the years. And make files are incompatible, which have -I options. All in all, this is a sad story of not so benevolent neglect for several decades. Fixing all this without breaking anything will be a long, tedious job.