为c ++标准库配置clang-check [英] Configure clang-check for c++ standard libraries
问题描述
我正在尝试以Ale作为我的林特,而后者又使用clang-check来完成我的代码。
I am trying to run Ale as my linter, which in turn uses clang-check to lint my code.
$ 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 ++编译仅返回警告。
Whereas compiling with clang++ returns only a warning.
$ 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-check的标志,允许我设置编译标志。
There are no flags to clang-check allowing me to set compilation flags.
推荐答案
花点时间弄清楚这个,但是你可以做
Took a while to figure this out, but you can do
clang-check file.cxx--Wall -std = c ++ 11 -x c ++
或者如果您使用的是整洁的
or if you are using clang-tidy
clang-tidy file.cxx--Wall -std = c ++ 11 -x c ++
要同时使用ALE,我将以下内容添加到我的vimrc
To get both working with ALE, I added the following to my vimrc
let g:ale_cpp_clangtidy_options ='-Wall -std = c ++ 11 -x c ++'
让g:ale_cpp_clangcheck_options ='--Wall -std = c ++ 11 -x c ++'
ALE也适用于C,对于 g:ale_c_clangtidy_options
,您也必须这样做和 g:ale_c_clangcheck_options
。
If you want ALE to work for C as well, you will have to do the same for g:ale_c_clangtidy_options
and g:ale_c_clangcheck_options
.
这篇关于为c ++标准库配置clang-check的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!