cppcheck

C++

情報源

Ubuntu 9.04にて

$ sudo aptitude install cppcheck

取得:1 http://jp.archive.ubuntu.com jaunty/universe cppcheck 1.27-2 [82.8kB]

$ cppcheck
cppcheck 1.27

C/C++ code checking

Syntax:
    cppcheck [--all] [--force] [--quiet] [--style] [--verbose] [file or path1] [file or path]

If path is given instead of filename, *.cpp, *.cxx, *.cc and *.c files are 
checked recursively from given directory.

Options:
    -a, --all        Make the checking more sensitive. More bugs are detected,
                     but there are also more false positives
    -f, --force      Force checking on files that have "too many" configurations
    -q, --quiet      Only print error messages
    -s, --style      Check coding style
    -v, --verbose    More detailed error reports

Example usage:
  # Recursively check the current folder. Print the progress on the screen and write errors in a file:
    cppcheck . 2> err.txt
  # Recursively check ../myproject/ and print only most fatal errors:
    cppcheck --quiet ../myproject/
  # Check only files one.cpp and two.cpp and give all information there is:
    cppcheck -v -a -s one.cpp two.cpp

いかにも変な感じのコードで試してみたのだが、何も警告してくれない。

#include <stdio.h>
main()
{
  char *a;
  a[0] = 'a';
    printf("hello %s", a);
}
#include <vector>
#include <iostream>
using namespace std;
main ()
{
  std::vector<int> vv;
  for (std::vector<int>::iterator it = vv.begin(); it != vv.end(); ++it) {
    cout << (*it) << endl;
    if (*it == 1) {
      vv.push_back(1);
    } 
  }
}

cppcheck.txt · 最終更新: 2011/11/08 20:43 by Takuya Nishimoto
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0