配置c ++标准库的clang-check

Bab*_*ack 1 c++11 clang++

我试图运行Ale作为我的linter,然后使用clang-check来lint我的代码.

$ 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.
Run Code Online (Sandbox Code Playgroud)

而使用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]
Run Code Online (Sandbox Code Playgroud)

clang-check没有标志允许我设置编译标志.

Kri*_*ann 8

花了一段时间来解决这个问题,但你可以做到

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工作,那你就必须为g:ale_c_clangtidy_options和做同样的事情g:ale_c_clangcheck_options.