Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ #inlcude root directory header

Started by JoeZ Jan 22, 2005 at 10:24 PM 4 replies 1.5k views
Original Post
JoeZ
JoeZ
Hi, I would just like to know if your current file is in Project folder > sub-folder > current file Is it possible include header files from the project folder (root folder)? (I know if your current file is in Project folder you can include headers in a sub-folder like this #include "sub-folder/something.h") Thanks!
Drew_Benton
Drew_Benton
Varations:
#include "../Different SubFolder/yourfile.h"
#include "../yourfile.h"
#include "../../yourfile.h"

[edit] The one in bold is the correct one I believe.

- Drew
JoeZ
JoeZ
Thanks Drew Benton!
psykr
psykr
I like setting things up so that #include directives work from your parent project directory, so you don't have to use relative paths. I started doing this when I found it hard to find files, and started moving files around a lot, but I've kept the habit ever since. For instance, instead of #include <../../smart_ptr.hpp>, you can now do #include
_the_phantom_
_the_phantom_
I find the best system to use is to have stuff which doesnt change very often and you use often, or are big, in your IDE's set of paths (so SDK headers etc) and use relative paths for stuff in the same project.
For libs which you dont use often the doing as psykr says and setting their paths per project is often a good plan, althought in that situation i'd be tempted to move small libraries into the project dir, so I know I'll be using the same stuff AND it makes it easier when others work on the same project/you distro the source.

As noted, this is a personal thing, it just seems to work well.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.