我现在使用 Visual Studio 2017 开发程序已有一段时间了。最近我安装了 Clang Power Tool 扩展以检查我的代码质量。我的程序的一部分包括模拟 cpu 的操作码。我在下面创建了一个精简的示例。
以下示例工作正常:
class C{};
inline void andi(C& s);
int main()
{
std::cout << "Hello, world!\n";
}
Run Code Online (Sandbox Code Playgroud)
这个没有:
class C{};
inline void and(C& s);
int main()
{
std::cout << "Hello, world!\n";
}
Run Code Online (Sandbox Code Playgroud)
我在 Clang 3.8.0 上收到这些错误(我在我的程序上使用 9.0.1 版,错误类似):
source_file.cpp:9:18: error: expected ')'
inline void and(C& s);
^
source_file.cpp:9:16: note: to match this '('
inline void and(C& s);
^
source_file.cpp:9:13: error: cannot form a reference to 'void'
inline void and(C& s);
^ …
Run Code Online (Sandbox Code Playgroud) 我是第一次使用 clang-tidy。我正在使用 OpenCV 完成我的论文。我的问题是,当我将 clang-tidy 配置为“修复”它发现的问题时,它也会修复它在 OpenCV 库中发现的问题。我的问题是:如何才能使 clang-tidy 只修复它在我创建的文件中发现的问题?
开发人员正在复制并粘贴相似类型的代码,并在其中而不是代码中犯了错误
int x = 100;
int y = 100;
int z = 100;
aFunction(x, y, z);
Run Code Online (Sandbox Code Playgroud)
他们不小心打字了
int x = 100;
int y = 100;
int z = 100;
(x, y, z); //What does this Line of Code do?
Run Code Online (Sandbox Code Playgroud)
此代码已成功编译,并未发出警告.尝试在VS 2015中调试此代码时,调试器将跳过此行代码.
为什么这行代码编译并且没有发出警告,这行编码是做什么的?
更新: 在Visual Studio 2015中构建所有警告显示此警告,但级别4不显示.奇怪的是,Code Analysis和Clang Power Tools都没有显示此警告.
谢谢.