We are currently using cppcheck2.7 for our project written in C using , however when we updated to cppcheck2.8 the misra addon crashes. When reverting to 2.7, it does not crash anymore, so this is a regression.
The error that appears (output from VS Code):
Strange! I don't know what goes wrong.
Do you know what command cppcheck is executed with. Can you reproduce the same output on the normal command line?
Can you see if there are files in /mnt/c/XXXXXXXXXX/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All the /mnt/c/XXXXXXXXXX/ are different paths, so I should have written /mnt/c/XXXX /mnt/c/YYYY etc, but yes I can verify that there are files in all those paths. However I can´t find any file named cppcheck-addon-ctu-file-list, but perhaps it becomes cleaned up after crash?
Running cppcheck command from terminal works fine. It´s only with cmake integration (used by setting CMAKE_C_CPPCHECK) the problem occurs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you clarify more how we reproduce. I am no expert on cmake. And I haven't used CMAKE_C_CPPCHECK .. that is not something that is provided by the cppcheck project.
I have created a small helloworld project where I defined the CMAKE_C_CPPCHECK variable. It just compiles I see no cppcheck analysis.
Is it not so that CMAKE_C_CPPCHECK is a variable set by find_program() trying to see if cppcheck is available. And it might not even be in 'upstream' CMake yet. And CMAKE_C_CPPCHECK is supposed to contain the command line to run cppcheck. So it depends on the implementation to find cppcheck what it puts into CMAKE_C_CPPCHECK. So if you can get the content of CMAKE_C_CPPCHECK you will see how cppcheck is run.
Last edit: Jens Yllman 2022-06-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I´m not sure how you mean that CMAKE_C_CPPCHECK migh not be 'upstream'? It is a feature in cmake since 3.10 release at least.
But yes you can use find_program() to find the cppcheck binary.
Here is my modified version of the cmake file which works to compile helloworld for me, but the previous example probably worked for Daniel's local build as well.
Hi,
We are currently using cppcheck2.7 for our project written in C using , however when we updated to cppcheck2.8 the misra addon crashes. When reverting to 2.7, it does not crash anymore, so this is a regression.
The error that appears (output from VS Code):
Strange! I don't know what goes wrong.
Do you know what command cppcheck is executed with. Can you reproduce the same output on the normal command line?
Can you see if there are files in
/mnt/c/XXXXXXXXXX/
Hi,
All the /mnt/c/XXXXXXXXXX/ are different paths, so I should have written /mnt/c/XXXX /mnt/c/YYYY etc, but yes I can verify that there are files in all those paths. However I can´t find any file named cppcheck-addon-ctu-file-list, but perhaps it becomes cleaned up after crash?
Running cppcheck command from terminal works fine. It´s only with cmake integration (used by setting CMAKE_C_CPPCHECK) the problem occurs.
Cppcheck removes that after analysis. It's unfortunate in this case :-(
ok interesting I wonder what cmake does differently.
I assume your project is not open source?
Can you reproduce same problems on some open source project? i.e. cppcheck.
https://github.com/danmar/cppcheck/archive/refs/tags/2.8.tar.gz
Simple commands to build:
tar xzvf 2.8.tar.gz
cd cppcheck-2.8
mkdir build
cd build
cmake ..
make
The project is not open source indeed.
Can you clarify more how we reproduce. I am no expert on cmake. And I haven't used CMAKE_C_CPPCHECK .. that is not something that is provided by the cppcheck project.
I have created a small helloworld project where I defined the CMAKE_C_CPPCHECK variable. It just compiles I see no cppcheck analysis.
Is it not so that CMAKE_C_CPPCHECK is a variable set by find_program() trying to see if cppcheck is available. And it might not even be in 'upstream' CMake yet. And CMAKE_C_CPPCHECK is supposed to contain the command line to run cppcheck. So it depends on the implementation to find cppcheck what it puts into CMAKE_C_CPPCHECK. So if you can get the content of CMAKE_C_CPPCHECK you will see how cppcheck is run.
Last edit: Jens Yllman 2022-06-19
I´m not sure how you mean that CMAKE_C_CPPCHECK migh not be 'upstream'? It is a feature in cmake since 3.10 release at least.
But yes you can use find_program() to find the cppcheck binary.
Here is my modified version of the cmake file which works to compile helloworld for me, but the previous example probably worked for Daniel's local build as well.
If I run:
Then to build:
I get the following output:
You can see that cmake runs cppcheck with same input as gcc with something called "cmake -E __run_co_compile --cppcheck"
If then modify 1.c with something that clearly generates a warning like adding unused function and clean rebuild, the warnings are output.
One detail I´m not sure if it matters is that we are using Ninja instead Make, for the cmake build.
ok I can reproduce similar output as you get in your last comment.
I see no FileNotFoundError when I run with --addon=misra. It's not too easy to reproduce.
You obviously have some other
CPPCHECK_ARGS_DEFAULT
arguments.Did you try to repeat those arguments exactly on the command line? And then it does not crash? But if you run
cmake --build . -v
it crashes?