Is there a style checker for c++?

2019-03-11 14:58发布

I have worked with java for a while now, and I found checkstyle to be very useful. I am starting to work with c++ and I was wondering if there is a style checker with similar functionality. I am mainly looking for the ability to write customized checks.

3条回答
兄弟一词,经得起流年.
2楼-- · 2019-03-11 15:43

What about Vera++ ?

Vera++ is a programmable tool for verification, analysis and transformation of C++ source code. Vera++ is mainly an engine that parses C++ source files and presents the result of this parsing to scripts in the form of various collections - the scripts are actually performing the requested tasks.

Click here to see a more complete demo of what it can do.

crc.hpp:157: keyword 'explicit' not followed by a single space
crc.hpp:588: closing curly bracket not in the same line or column
dynamic_property_map.hpp:82: keyword 'if' not followed by a single space
functional.hpp:106: line is longer than 100 characters
multi_index_container.hpp:472: comma should be followed by whitespace
version.hpp:37: too many consecutive empty lines
weak_ptr.hpp:108: keyword 'catch' not followed by a single space
...
查看更多
beautiful°
3楼-- · 2019-03-11 15:51

I have had good feedback about Artistic Style which allows to apply a uniform style on code without too much hassle.

It's free and there are plenty of "classic" styles already defined. It might not work with C++0x new constructs though.

I am also expecting a Clang library, though I haven't found any to date. Normally, given Clang's structure it should be relatively easy, but then it's always easier to say than to code and I guess nobody took the time yet.

查看更多
Luminary・发光体
4楼-- · 2019-03-11 15:52

KWStyle seems to be a lightweight fit

查看更多
登录 后发表回答