Context:
* I'm using Cppcheck 2.13.0
* I'm trying to run cppcheck on a cross-compiled project, so I do not use the default system includes
* After reading some documentation and code in the github repository I found that "configuration for the standard libraries of C and C++, std.cfg, is always loaded by cppcheck".
Problem:
I'm trying to get rid of the missingIncludeSystem the correct way which is by specifying the paths for the files/dirs, instead of using the --supress=missingIncludeSystem. In some files where I am able to achieve this I even get new code warnings, which is a good thing, but as a result I get false syntax error in some system include files like math.h.
I understood that this is due to the load of some configurations present in file cppcheck/cfg/ std.cfg that conflict with the cross-tools header files.
As an example:
This enum exists in my cross-compilation math.h file:
Consequently it results in syntax error detected by cppcheck when analyzing the file or any file that includes it!
math.h:915:3:error:syntaxerror:5=[syntaxError]
What I propose here is for cppccheck not load anything automatically or to create a new cppcheck flag to not load any config file automatically, for example: --no-auto-config
Thanks
Last edit: André Coquim 2024-12-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not loading std.cfg is really not advisable due to the information about library functions etc. that it contains. In your case, couldn't you use a patched .cfg without the offending values?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To prove everything I said I have changed the content of std.cfg to make it "empty":
<?xml version="1.0"?><defformat="2"></def>
This solved the problem, but I was using a version that I downloaded personally for me.
In a corporative environment I don't have root privileges in the machine so I cannot do such a thing. Also, each time Cppcheck is upgraded the same fix is needed and this approach is not convenient since I don't have root privileges.
I understand that not loading by default may not be advisable, but that's why I proposed a new flag like --no-auto-config to be able to not load this file as an option.
Thanks
Last edit: André Coquim 2024-12-06
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Context:
* I'm using Cppcheck 2.13.0
* I'm trying to run cppcheck on a cross-compiled project, so I do not use the default system includes
* After reading some documentation and code in the github repository I found that "configuration for the standard libraries of C and C++, std.cfg, is always loaded by cppcheck".
Problem:
I'm trying to get rid of the missingIncludeSystem the correct way which is by specifying the paths for the files/dirs, instead of using the --supress=missingIncludeSystem. In some files where I am able to achieve this I even get new code warnings, which is a good thing, but as a result I get false syntax error in some system include files like math.h.
I understood that this is due to the load of some configurations present in file cppcheck/cfg/ std.cfg that conflict with the cross-tools header files.
As an example:
This enum exists in my cross-compilation math.h file:
When I run cppcheck with preprocessor:
cppcheck math.h -E
I can see that the result becomes:
The correct result should be:
This happens because std.cfg is being loaded with this configurations:
Consequently it results in syntax error detected by cppcheck when analyzing the file or any file that includes it!
What I propose here is for cppccheck not load anything automatically or to create a new cppcheck flag to not load any config file automatically, for example: --no-auto-config
Thanks
Last edit: André Coquim 2024-12-01
Not loading std.cfg is really not advisable due to the information about library functions etc. that it contains. In your case, couldn't you use a patched .cfg without the offending values?
To prove everything I said I have changed the content of
std.cfg
to make it "empty":This solved the problem, but I was using a version that I downloaded personally for me.
In a corporative environment I don't have root privileges in the machine so I cannot do such a thing. Also, each time Cppcheck is upgraded the same fix is needed and this approach is not convenient since I don't have root privileges.
I understand that not loading by default may not be advisable, but that's why I proposed a new flag like
--no-auto-config
to be able to not load this file as an option.Thanks
Last edit: André Coquim 2024-12-06
Using
--supress=missingIncludeSystem
is the way to go, making standard headers visible to cppcheck serves no purpose. That's why std.cfg exists.