The structure of the folder of my source code is defined as follows:
g++ -I./ -MM -MT c/c.o -MF c/c.d c/c.cpp
According to this GCC webpage, the
"preprocessor looks for header files included by the quote form of the directive
#include "file"first relative to the directory of the current file, and then in a preconfigured list of standard system directories."
That means when it sees
#include "c/c.h", it checks for files in a hypothetical subdirectory named "c" from the current file's location.
When you replaced that with
#include "c.h", the preprocessor then checks the directory of the current file.
Another option is to add
-I../ to the command line parameters for g++.
This GCC webpage provides the complete order in which the preprocessor searches directories for include files. The lookup order is as follows:
Note that the directory from which you ran g++ does not appear on the above list. This means, the preprocessor does not check the directory from which you ran g++ on the command line. The reason is so that you can run g++ from any directory and still get the same build results.