My physical file structure for a project I have is something like:
- Source folder
- Engine
- Folder1
- Folder2
etc.
I have some files in ‘Source’, some in ‘Engine’, some in ‘Engine/Folder1’, etc.
On my project, I have gone All Configurations->Source Directories and included Source, Engine, Engine/Folder2, etc. However, I still get errors that it cannot find files when I try to include “Foo.h” or whatever from a different folder. Is there a way to make it so I don’t have to have ../Folder1/ in front of everything?
Yes, there is. The answer depends on several factors and I’m sure I’ll miss a few.
Check the following:
If you use “foo.h” (rather than <foo.h>) the preprocessor will look in your project specific folders first and in the IDE specific folders last. If you use <foo.h> it starts in the standard include folders first, e.g. those that are required for standard runtime libraries.
When a file uses “../foo.h” its a path relative to the location of the file that includes the file. There can be tricky exceptions.
There are many more things that can influence how the preprocessor finds its include paths. If you are unsure what the preprocessor is doing with a particular file you can make the preprocessor output visible by switch on “Preprocess to a file” in the preprocessor settings. The file shows you the source code for a file after the preprocessor is finished and before the compiler starts its work.
The whole thing becomes much easier with more experience and in particular a clear strategy for the folder/project structure and how to include files. For example make sure you have “#pragma once” as the first non-comment line in each include file.
I hope this gives you a few ideas for the next steps. Good luck!