37

cppcheck can't find even standard headers such as iostream. Any ideas?

I am using Ubuntu 11.04 and cppcheck from the repository.

Bart
  • 19,692
  • 7
  • 68
  • 77
pic11
  • 14,267
  • 21
  • 83
  • 119
  • Check if they are installed... – eugene_che Aug 08 '11 at 17:28
  • 1
    @tyz: I think the idea is that cppcheck knows about ANSI/C++ w/o any headers. So I think it won't even understand gcc specific system headers etc.. –  Aug 08 '11 at 17:33

2 Answers2

39

cppcheck is really bad at finding standard include headers, on Mac and Linux. Fortunately, you can suppress this check, and only scan your custom header files:

cppcheck --enable=all --suppress=missingIncludeSystem .
mcandre
  • 22,868
  • 20
  • 88
  • 147
  • 5
    This supress-flag gives me the following error: `Unmatched suppression: missingIncludeSystem`... Or does this simply mean that the check didn't suppress any arror? Can I suppress the non-suppressed suppress-error then? O:) – helmesjo Aug 22 '17 at 05:21
  • 3
    Yes, you can suppress the 'unmatched suppression' error, with --suppress=unmatchedSuppression. :) – Eric Backus Jul 15 '20 at 16:54
  • 1
    Judging by the man page,I think this is named `missingInclude` now. – gerowam Jun 21 '23 at 12:56
24

It isn’t recommended to provide the paths to the standard C/C++ headers - Cppcheck has internal knowledge about ANSI C/C++ and it isn’t recommended that this known functionality is redefined. But feel free to try it.

-I [dir]

Give include path. Give several -I parameters to give several paths. First given path is checked first. If paths are relative to source files, this is not needed.

yegor256
  • 102,010
  • 123
  • 446
  • 597