How to #include a file in a subdirectory?

Started by
3 comments, last by GameDev.net 19 years, 3 months ago
Hi I have some header files in a subdirectory and I want to include them in my main header. I don't want to add the folder to the directories link in the project I just want to do something like this #include "/folder/class.h" but for some reason its not finding it.
Advertisement
Remove the first slash, otherwise it'll look in the root directory. Use:

#include "folder/class.h"
Harry.
If you have this structure
- Some Main Folder   - Folder 1      - File1.h   - Folder 2      - File2.h   - Project Folder      - File.cpp


You would have to do:

#include "../folder 1/file1.h"


If you have this structure
- Project Folder   - File.cpp   - Folder 1      - File1.h   - Folder 2      - File2.h   


You would have to do:

#include "folder 1/file1.h"


As HarryW has said.

- Drew
It says no such file or directory. edit the ../ in front worked thanks you guys
probably because you tried his first method in a directory structure resembling the second method.

This topic is closed to new replies.

Advertisement