Reputation: 41
I am about to start writing a code in C++ for my PhD. Until now I worked with small code. All the files (sources and headers) in one directory.
Since I want to write a more organized code, I'll put files in different directories.
So what is the proper way to include files? Should I use something like
#include "../../folder/file.hpp"
It doesn't look very clean. And is the code portable to Windows if includes are done this way?
Upvotes: 3
Views: 1098
Reputation: 238311
is the code portable to Windows
I don't see a reason why it wouldn't be, as long as you fix the syntax of the directive first. I don't have a windows to test at the moment, but that's a valid path.
However, I would recommend to avoid parent directory include paths. Instead, specify a directory as an include directory for the compiler, put all your headers there into sub-directories and include with a path relative to the include directory.
Upvotes: 4