Include Directors

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:

globals.h

thing.h
animal/worm.h
animal/mammals/dog.h
animal/mammals/cat.h
animal/reptile.h
vehicle/boat/battleship.h
vehicle/boat/canoe.h
vehicle/train.h
planet/Mars.h
planet/Earth.h

Now, suppose I wanted to include all of these in dog.h
Right now I'd have to do this:

1
2
3
4
5
6
7
8
9
10
// dog.h
#include "../../thing.h"
#include "cat.h"
#include "../worm.h"
#include "../reptile"
#include "../../vehicle/boat/battleship.h"
#include "../../vehicles/boat/canoe.h"
#include "../../train.h" 
#include "../../planet/Mars.h"
#include "../../planet/Earth.h" 


I find this highly aggravating. What I want to do is to be able to go:

1
2
3
4
5
6
7
8
9
10
// dog.h
#include thing.h
#include animal/worm.h
#include animal/mammals/cat.h
#include animal/reptile.h
#include vehicle/boat/battleship.h
#include vehicle/boat/canoe.h
#include vehicle/train.h
#include planet/Mars.h
#include planet/Earth.h 


I've seen other projects be able to do it like this. How do I make mine use this system?
I can't replicate your problem when I try your setup with VC++2008, VC++2010, or VC++2012
LB: I'm using the folders in the file system to organize my files, not Visual Studio's filters, if that helps.
Yes, I know. I even tested with two files with the same name but in different 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.
Topic archived. No new replies allowed.