编码风格检查对C [英] Coding style checker for C

查看:129
本文介绍了编码风格检查对C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为有严格的编码风格的指导方针,但没有自动工具来验证他们的公司。我环顾四周,唯一的工具,我能找到的都是像皮棉,似乎旨在验证code做什么工具,以及preventing的错误,而不是在确保编码风格是正确的。

I'm working for a company that has strict coding style guidelines but no automatic tool to validate them. I've looked around and the only tools I could find were lint like tools that seem to be aimed at verifying what the code does, and preventing bugs and not at making sure the coding style is correct.

我们应该使用什么工具,如果在所有?

What tool should we use, if at all?

请注意:我在寻找的东西C code,虽然一些C ++的工作将是一件好事,以及

NOTE: I'm looking for something for C code, although something that works for C++ would be good as well.

推荐答案

传统的美化缩进,可用每个Unix机器上。一些找到的版本是 GNU缩进,可以编译和安装每台机器上。 GNU缩进可以从文件中读取的一套规则〜/ .indent.pro ,例如:

The traditional beautifier indent, available on every Unix machine. The version found on some is GNU indent, which can be compiled and installed on every machine. GNU indent can read a set of rules from the file ~/.indent.pro, for instance:

--original --dont-format-first-column-comments --no-blank-lines-after-commas --parameter-indentation 8 --indent-level 8 --line-length 85 --no-space-after-parentheses --no-comment-delimiters-on-blank-lines

所以,仅仅commiting的presentation担保均匀运行前缩进。如果你想为实施它定义了一个$ P $的版本控制系统使用,这将缩进运行P-commit挂钩,并拒绝,如果提交的版本,从生产什么缩进不同的提交。

So, just running indent before commiting guarantees uniformity of the presentation. If you want to enforce it, define a pre-commit hook in the Version Control System you use, which will run indent and refuse the commit if the committed version differs from what indent produces.

这篇关于编码风格检查对C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆