cppcheck
cppcheck copied to clipboard
I don't think cppcheck should warn if it can't find the standard header files
I've just adjusted lib/preprocessor.cpp
so that it will not warn anyone it can't find the header files.
My idea here is that if this
Please note: Cppcheck does not need standard library headers to get proper results.
is true, then the user shouldn't have to worry about whether the headers not found are ones Cppcheck also doesn't need.
Is this kind of thing good? In that case, it's trivial to add more filenames to ignore for this specific case.
Gah! I realize now the branch is marred by the inclusion of commits from my other PR. Let me know if there's a problem here and I'll try to right it.
This could actually be useful to detect missing custom/user-generated header files, which might be required for proper analysis (cf. various daca@home errors). Of course, your list is very much incomplete...
I am not sure. I do develop Cppcheck for the use case that the stdio etc are not included. I never include system headers when I run Cppcheck myself. But technically it is possible to include the system headers and run cppcheck with that. Unfortunately I can image some bugs that can only be detected if the system headers are included. For instance if you use a standard struct that is not defined in std.cfg and have uninitialized member usage.
We could clarify the information message and say something like "we recommend that you use --library=std instead of including stdio.h" maybe?
And yes as @chrchr-github says the list of headers will definitely be incomplete always.
You can suppress the warnings about system headers with --suppress=missingIncludeSystem
.
I also think we should split the --enable=
option missingInclude
into a local and system version (I though I had a ticket field about this).
There's also an idea to move the library detection used in daca into the application so you don't have to manually specify --library
. And there would be a different warning which would actually tell you about system headers which are not represented - see https://trac.cppcheck.net/ticket/11287 for much more detail.
I see no upside in the suggested change and think the proposed improvements might cover the intention of this change. So this PR should be closed.
I close this. I think the interface can be discussed though .. if you have a sourceforge account feel free to open a discussion thread there..