I have some header files contained in sub directories of the project source. Having to do #include "../../Foo.h"
inside these files looks kinda messy in my opinion, when I'd much prefer to do #include "dir1/dir2/Foo.h"
for faster human reading and understanding - is this possible, and if so, how?
Obviously you can. (And should)
Tell the compiler to add "projectdir/../.." to its include path. On Microsoft this would be using the /I
switch, on gcc it's -I
.
---- edit -----
In Visual Studio, you can use 'Macros'. In this case $(ProjectDir)/../..
should do.
Better still, if you can organize it that way: create a solution in the 'root' dir, add projects in subdirs, and use $(SolutionDir)/projectX/includes
on your C++ include path.
Even more better still: add the dependent project as a Reference to your project. VS should automatically add its directory and lib to the compiler and linker settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With