Coding style checker for C

2019-01-21 11:39发布

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?

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

9条回答
可以哭但决不认输i
2楼-- · 2019-01-21 12:12

There are (or were) numerous tools for this. One of the oldest is cb (C Beautifier) that was around in ancient versions of Unix - meaning, in this case, Version 7 Unix:

CB ( 1 ) UNIX Programmer’s Manual CB ( 1 )

NAME
    cb – C program beautifier
SYNOPSIS
    cb
DESCRIPTION
   Cb places a copy of the C program from the standard input on the standard
   output with spacing and indentation that displays the structure of the
   program.
BUGS

GNU indent is a vastly more complex and configurable beastie. There were commercial tools as well. For example, Abraxas Software provides a CodeCheck tool, for example; we used that briefly in the mid-90s, but the changes it wanted us to make were (very necessary, but) too intrusive for management.

查看更多
孤傲高冷的网名
3楼-- · 2019-01-21 12:13

From a similar question: Vera++:

Vera++ is a programmable tool for verification, analysis and transformation of C++ source code.

The main usage scenarios that are foreseen for Vera++ are:

Ensure that the source code complies with the given coding standards and conventions.

Provide source code metrics and statistics.

Perform automated transformations of the source code, which can range from pretty-printing to diagnostics to fault injection and advanced testing.

查看更多
\"骚年 ilove
4楼-- · 2019-01-21 12:20

Please use VIM and enjoy the easiness. You can do anything related to source programming by simple commands. Also you can make the VIM more reliable and powerful by editing .vimrc file. The help in it will help you a lot.

/renjith g

查看更多
登录 后发表回答