小编Wam*_*itz的帖子

如何在 Windows 上使用和配置 clang-tidy?

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

// test.cpp
#include <iostream>

int main(int argc, char const *argv[])
{
    std::cout << "Hello World!" << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

然后我在终端运行这个:

clang test.cpp
Run Code Online (Sandbox Code Playgroud)

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

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

但是它在打印“Hello World”之前运行良好,并且在此之前一切正常,但是当我想运行 clang-tidy 时,我在运行时得到以下输出,我从Extra Clang Tools …

c++ clang clang-tidy

5
推荐指数
1
解决办法
4485
查看次数

在哪个 ISO C++ 版本中引入了迭代器?

当迭代器被引入 ISO C++ 时,我正在寻找参考,我可以注意到在这个例子中它们自 C++98 以来与向量一起使用,但我从www.isocpp.com页面读到这不是官方文档但只是参考:http : //www.cplusplus.com/reference/vector/vector/vector/

// constructing vectors
#include <iostream>
#include <vector>

int main ()
{
  // constructors used in the same order as described above:
  std::vector<int> first;                                // empty vector of ints
  std::vector<int> second (4,100);                       // four ints with value 100
  std::vector<int> third (second.begin(),second.end());  // iterating through second
  std::vector<int> fourth (third);                       // a copy of third

  // the iterator constructor can also be used to construct from arrays:
  int myints[] = {16,2,77,29};
  std::vector<int> …
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
90
查看次数

标签 统计

c++ ×2

clang ×1

clang-tidy ×1