Hi, I'm using Visual Studio 2010 and I'm trying to build a project that includes the following files:
main.h
globals.h
dir/console.h
The file console.h is in it's own directory. I'm trying to get console.h to include global.h in the directory down from it. What settings do I need to configure to be able to use just:
1 2
// Console.h
#include "globals.h"
instead of:
1 2
// Console.h
#include "../globals.h"
I'm sure I've set it up to work like this in another project but I can't for the life of me remember how I did it.
You would have to add the existing globals.h file to your project. So on the left where you typically add your source files you would right click on "Header files" and click "Add --> Existing Item". You would then locate the globals.h file in it's directly and add it to the project.
Once the file itself is in your project, you should be able to use #include "globals.h".
You seem to misunderstand. Globals.h is alread included. Other files are including it just fine. The problem is that including it from another directory.
Let me explain a little better. Supposing I have the following files and directories:
As long as it's in the same project even if it's in different folders you should still be able to include them like normal without having at add the directories.