Say we have a .cpp file A including a .h file B which includes a .h file C.
// File A.cpp
#include "B.h"
...
// File B.h
#include "../../utilityies/C.h"
...
If B includes C using a relative path, is that relative path resolved relatively to the location of B or to the location of A which is the .cpp that B is going to be copy-pasted into ?
The include path is relative to the file containing it so in your case relative to the location of B.
From the gcc docs:
GCC looks for headers requested with #include "file" first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets. For example, if /usr/include/sys/stat.h contains #include "types.h", GCC looks for types.h first in /usr/include/sys, then in its usual search path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With