尝试设置flycheck-clang-include-path而不需要包含项目的完整路径包括使用projectile的目录,但是我收到错误......所以这有效:
((nil . (
(company-clang-arguments . (
"/home/user/Downloads/project/headers"
"/home/user/Downloads/project/source/mon"
))
(flycheck-clang-include-path . (
"/home/user/Downloads/project/headers"
"/home/user/Downloads/project/source/mon"
))
)))
但这不是:
((nil . (
(company-clang-arguments . (
(concat "-I" (projectile-project-root) "headers")
(concat "-I" (projectile-project-root) "source/mon")
))
(flycheck-clang-include-path . (
(concat (projectile-project-root) "headers")
(concat (projectile-project-root) "source/mon")
))
)))
报告的错误:
flycheck-substitute-argument: Value ((concat (projectile-project-root) "headers")) of flycheck-clang-include-path for option "-I" is not a list of strings
答案 0 :(得分:1)
一种可能性是使用eval
评估dir-locals
中引用的表单。这可能被认为是不安全的,因为任何事情都可以用这种形式进行评估。
((nil
(eval . (let ((root (projectile-project-root)))
(setq-local company-clang-arguments
(list (concat "-I" root "headers")
(concat "-I" root "source/mon")))
(setq-local flycheck-clang-include-path
(list (concat root "headers")
(concat root "source/mon")))))))