我使用自制软件在MacOS 10.13上安装了LLVM:
brew install --with-toolchain llvm
然后我基于this guide导出了必需的变量。
export PATH="/usr/local/opt/llvm/bin:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export CXX=/usr/local/opt/llvm/bin/clang++
export LLVM_OPTIONS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib "\
"-I/usr/local/opt/llvm/include -I/usr/local/opt/llvm/include/c++/v1/"
运行clang-tidy时:
clang-tidy myheaderlib.h -- $LLVM_OPTIONS
我收到错误,所有错误都与标准文件有关:
/usr/local/opt/llvm/include/c++/v1/iosfwd:96:1: error: unknown type name '_LIBCPP_BEGIN_NAMESPACE_STD'
/usr/local/opt/llvm/include/c++/v1/iosfwd:100:1: error: unknown type name 'template'
...
可能是什么原因?
答案 0 :(得分:0)
我发现,问题在于clang-tidy默认情况下将.h
文件视为C头文件。将其重命名为myheaderlib.hpp
可以解决此问题。我仍然很想听听如何正确配置clang-tidy,以便可以在不考虑文件扩展名的情况下指定语言。