cppcheck can't find include files

34,200

Solution 1

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 .

Solution 2

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.

Share:
34,200

Related videos on Youtube

pic11
Author by

pic11

I code in C, C++ and Python.

Updated on July 10, 2022

Comments

  • pic11
    pic11 almost 2 years

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

    I am using Ubuntu 11.04 and cppcheck from the repository.

    • eugene_che
      eugene_che almost 13 years
      Check if they are installed...
    • Admin
      Admin almost 13 years
      @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..
  • Drew Noakes
    Drew Noakes over 10 years
    The -I option can make cppcheck run very slowly if you bring in a lot of headers.
  • Andy Krouwel
    Andy Krouwel almost 9 years
    And don't get it mixed up with the '-i' (ignore) option.
  • helmesjo
    helmesjo almost 7 years
    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:)
  • tjysdsg
    tjysdsg about 5 years
    I think this is a better answer, at least for me, my headers are not in to project root directory. So if suppressing the warning no headers will be checked.
  • Eric Backus
    Eric Backus almost 4 years
    Yes, you can suppress the 'unmatched suppression' error, with --suppress=unmatchedSuppression. :)