What is the best method to include a file that has same name in another folder from additional include directories?
Example:
lib1/include/foo.h
lib2/
I would include the files from a unambiguous directory which is in the -I
list (That is to say the path to the directory which contains lib1 and lib2):
#include "lib1/include/foo.h"
#include "lib2/include/foo.h"
Therefore there will be no ambiguity because the precompiler will look at lib1/include/foo.h
within its directory list and that don't happen from lib1/include/
or lib2/include/
but only from the parent directory.
As said earlier: take care with the guards, even if for a lib header, the name should include the lib name to avoid such confusions.