cppcheck can't find include files
Asked Answered
A

2

43

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

I am using Ubuntu 11.04 and cppcheck from the repository.

Acoustics answered 8/8, 2011 at 17:26 Comment(2)
Check if they are installed...Mersey
@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..Suellen
S
47

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 .
Shurlock answered 5/11, 2013 at 0:1 Comment(3)
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:)Pergolesi
Yes, you can suppress the 'unmatched suppression' error, with --suppress=unmatchedSuppression. :)Vanish
Judging by the man page,I think this is named missingInclude now.Ascendant
S
29

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.

Suellen answered 8/8, 2011 at 17:31 Comment(3)
The -I option can make cppcheck run very slowly if you bring in a lot of headers.Ordinarily
And don't get it mixed up with the '-i' (ignore) option.Mydriasis
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.Toga

© 2022 - 2024 — McMap. All rights reserved.