如何在窗户上使用和配置叮当声?



我正在尝试使用clang-tidy代码分析,以便我可以检查CppCoreGuidelines。我下载了 LLVM 7.0.0 预构建的二进制文件 Win 7 64 位。我能够成功地用 clang 编译,我做了一个编译这段代码的基本示例,我命名了源测试.cpp:

// test.cpp
#include <iostream>
int main(int argc, char const *argv[])
{
std::cout << "Hello World!" << std::endl;
return 0;
}

然后我在终端中运行了这个:

clang test.cpp

编译时我得到了这个输出:

test-c4b051.o : warning LNK4217: locally defined symbol __std_terminate imported in function "int `public: static unsigned __int64 __cdecl std::char_traits<char>::length(char const * const)'::`1'::dtor$2" (?dtor$2@?0??length@?$char_traits@D@std@@SA_KQEBD@Z@4HA)
test-c4b051.o : warning LNK4217: locally defined symbol _CxxThrowException imported in function "public: void __cdecl std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QEAAXH_N@Z)

但是打印"Hello World"工作正常,直到这里一切都很好,但是当我想运行 clang-tidy 时,我在运行这个时会得到以下输出,我从这里获取了参考 额外的 Clang 工具 8 文档:

clang-tidy test.cpp -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*

Error while trying to load a compilation database:
Could not auto-detect compilation database for file "test.cpp"
No compilation database found in C:Usersuidr8361DesktopC++ or any parent directory
fixed-compilation-database: Error while opening fixed database: no such file or directory
json-compilation-database: Error while opening JSON database: no such file or directory
Running without flags.

我阅读了这个线程,但这似乎适用于 clang 编译,我不知道这是否也适用于 clang 额外的工具,尤其是 clang-tidy: 如何在 Windows 上编译 Clang

只需在最后的命令行上放置 -- (减去减号(

clang-tidy -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* test.cpp --

你通常会把你的cl,gcc,clang参数放在后面

clang-tidy -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* test.cpp -- -DDEBUG -I./include

最新更新