I want to use syntax checking with Flycheck in my C++ projects, but the Clang checker fails to find the local file includes. For example, when I have:
#include "foo/bar/x.h"
in the file foo2/y.cc
, it reports an error that it couldn't find the include file. Both foo/
and foo2/
are in the project root. I can work around this by adding the following to a .dir-locals.el
file in the project:
((c++-mode .
( (flycheck-clang-include-path . "/home/user/src/myproject") ) )
))
However, I have dozens of projects and it would be a lot of work to set this for each directory. I'm using Projectile and I think it should be possible to set the include path based on the project root automatically, but I cannot find any variable or function in Projectile that would return the path to the current project.