根据一组编码标准检查 C/C++ 源代码的免费工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/93260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 12:48:30  来源:igfitidea点击:

A free tool to check C/C++ source code against a set of coding standards?

c++ccoding-style

提问by Drealmer

It looks quite easy to find such a tool for Java (Checkstyle, JCSC), but I can't seem to find one for C/C++. I am not looking for a lint-like static code analyzer, I only would like to check against coding standards like variable naming, capitalization, spacing, identation, bracket placement, and so on.

为 Java 找到这样的工具(CheckstyleJCSC)看起来很容易,但我似乎找不到用于 C/C++ 的工具。我不是在寻找类似于 lint 的静态代码分析器,我只想检查编码标准,如变量命名、大写、间距、标识、括号放置等。

采纳答案by yrp

The only tool I know is Vera. Haven't used it, though, so can't comment how viable it is. Demolooks promising.

我知道的唯一工具是Vera。不过没用过,所以无法评价它的可行性。演示看起来很有希望。

回答by janesconference

回答by tatsuhirosatou

I'm sure this could help to some degree cxx checker. Also this tool seems to be pretty good KWStyleIt's from Kitware, the guys who develop Cmake.

我相信这在某种程度上可以帮助cxx checker。另外这个工具似乎很不错KWStyle它来自 Kitware,开发 Cmake 的人。

回答by Pieter

Not exactly what you ask for, but I've found it easier to just all agree on a coding standard astylecan generate and then automate the process.

不完全是您所要求的,但我发现让所有人都同意astyle可以生成然后自动化该过程的编码标准更容易。

回答by Joshua

Try nsiqcppstyle. It's a Python based coding style checker for C/C++. It's easy to extend to add your own rules.

试试nsiqcppstyle。它是一个基于 Python 的 C/C++ 编码风格检查器。很容易扩展以添加您自己的规则。

回答by EfForEffort

There's a list. There is also a putative C++ frontend on splint.

有一个清单在 splint 上还有一个假定的C++ 前端

回答by EfForEffort

Check universalindentguion sourceforge.net.

检查universalindentguisourceforge.net

it has many style checkers for C and you can customise the checkers.

它有许多用于 C 的样式检查器,您可以自定义检查器。

回答by udpsunil

I have used a tool in my work its LDRA tool suite

我在我的工作中使用了一个工具,它的LDRA 工具套件

It is used for testing the c/c++ code but it also can check against coding standards such as MISRA etc.

它用于测试 c/c++ 代码,但也可以检查编码标准,如 MISRA 等。

回答by Wernight

There is cppcheckwhich is supported also by Hudsonvia the plugin of the same name.

cppcheck它也支持哈德森通过相同名称的插件。

回答by Andrew

Check Metrix++ http://metrixplusplus.sourceforge.net/. It may require some extensions which are specific for your needs.

检查 Metrix++ http://metrixplusplus.sourceforge.net/。它可能需要一些特定于您的需求的扩展。