我正在尝试运行 Ale 作为我的 linter,它又使用 clang-check 来检查我的代码。
$ clang-check FeatureManager.h
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "FeatureManager.h"
No compilation database found in /home/babbleshack/ or any parent directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
/home/babbleshack/FeatureManager.h:6:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
^~~~~~~~~~~~~~~
1 error generated.
Error while processing /home/babbleshack/FeatureManager.h.
而使用 clang++ 编译仅返回警告。
$ clang++ -std=c++11 -Wall FeatureManager.cxx FeatureManager.h
clang-5.0: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
没有可供 clang 检查的标志,允许我设置编译标志。
花了一段时间才弄清楚这一点,但你可以做到
clang-check file.cxx -- -Wall -std=c++11 -x c++
或者如果你使用 clang-tidy
clang-tidy file.cxx -- -Wall -std=c++11 -x c++
为了让两者都能使用 ALE,我将以下内容添加到我的 vimrc 中
let g:ale_cpp_clangtidy_options = '-Wall -std=c++11 -x c++'
let g:ale_cpp_clangcheck_options = '-- -Wall -std=c++11 -x c++'
如果您希望 ALE 也适用于 C,则必须对 C 执行相同的操作g:ale_c_clangtidy_options
and g:ale_c_clangcheck_options
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)