Are there any lint tools for C and C++ that check formatting?

前端 未结 4 1912
后悔当初
后悔当初 2021-02-05 15:05

I have a codebase that is touched by many people. While most people make an effort to keep the code nicely formatted (e.g. consistent indentation and use of braces), some don\'

相关标签:
4条回答
  • 2021-02-05 15:16

    Google uses cpplint. This is their style guide.

    0 讨论(0)
  • 2021-02-05 15:27

    The Linux kernel uses a tool that does exactly this - it's called checkpatch. You'd have to modify it to check your coding standards rather than theirs, but it could be a good basis to work from. (It is also designed for C code rather than C++).

    0 讨论(0)
  • 2021-02-05 15:27

    Take a look at Vera++, it has a number of rules already available but the nice part is that you can modify them or write your own.

    0 讨论(0)
  • 2021-02-05 15:29

    There are several programs that can do formatting for you automatically on save (such as Eclipse). You can have format settings that everyone can use ensuring the same formatting.

    It is also possible to automatically apply such formatting when code is committed. When you use SVN, the system to do this is called svn hooks. This basically starts a program to process (or check and deny) the formatting when a commit happens.

    This site explains how you can make your own. But also ones already exist to do this.

    0 讨论(0)
提交回复
热议问题