Hello,
I am using CppCheck tool to run static code analysis on my embedded project. Here, I am using 32bit g++ compiler. I have generated compile_commands.json file which has the flag --sysroot.
I am using Cppcheck 1.90 on Ubuntu 20.04LTS
This is the command. cppcheck --project=build/compile_commands.json --check-config
When i run this code, it throw file include error /home/user/embedded_proj/can/src/canapp.cpp:20:0: information: Include file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]
/home/user/embedded_proj/can/src/canoutp.cpp:15:0: information: Include file: <thread> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]
Just curious despite setting the sysroot variable cppcheck is complaining about missing include files.
Is this something, that I am missing something?
Thanks,
Last edit: Ginson Mathew 2024-05-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I recommend that the include paths for cstring and thread is not specified that can lead to false negatives. The standard functions are understood by internal knowledge in cppcheck. Please suppress or ignore missingIncludeSystem warnings for standard C/C++ headers. And for other 3rd party headers it's also usually better to use --library=.. when possible.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One reason there can be false negatives, I have seen cases when system headers define various functions using macros. For instance there is such code:
#define strcpy(d, s) __builtin_strcpy ((d), (s))
If you provide that to Cppcheck it will not be able to detect strcpy misuse.
Another reason there can be false negatives is that sometimes there are complex ifdefs, templates, etc that is nontrivial to configure well. To start with, Cppcheck is not aware of all macros defined by your arbitrary compiler..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am using CppCheck tool to run static code analysis on my embedded project. Here, I am using 32bit g++ compiler. I have generated compile_commands.json file which has the flag
--sysroot
.I am using
Cppcheck 1.90
on Ubuntu 20.04LTSThis is the command.
cppcheck --project=build/compile_commands.json --check-config
When i run this code, it throw file include error
/home/user/embedded_proj/can/src/canapp.cpp:20:0: information: Include file: <cstring> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]
/home/user/embedded_proj/can/src/canoutp.cpp:15:0: information: Include file: <thread> not found. Please note: Cppcheck does not need standard library headers to get proper results. [missingIncludeSystem]
Just curious despite setting the sysroot variable cppcheck is complaining about missing include files.
Is this something, that I am missing something?
Thanks,
Last edit: Ginson Mathew 2024-05-28
I recommend that the include paths for cstring and thread is not specified that can lead to false negatives. The standard functions are understood by internal knowledge in cppcheck. Please suppress or ignore missingIncludeSystem warnings for standard C/C++ headers. And for other 3rd party headers it's also usually better to use
--library=..
when possible.One reason there can be false negatives, I have seen cases when system headers define various functions using macros. For instance there is such code:
If you provide that to Cppcheck it will not be able to detect strcpy misuse.
Another reason there can be false negatives is that sometimes there are complex ifdefs, templates, etc that is nontrivial to configure well. To start with, Cppcheck is not aware of all macros defined by your arbitrary compiler..