How to #include a file in a subdirectory?
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.
Remove the first slash, otherwise it'll look in the root directory. Use:
#include "folder/class.h"
If you have this structure
You would have to do:
If you have this structure
You would have to do:
As HarryW has said.
- Drew
- 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
probably because you tried his first method in a directory structure resembling the second method.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement