I'm trying to use CppCheck on a Visual Studio solution. But, when I use the 'Analyze/Files...' menu option and select the .sln file, it checks only 1 included directory and none of the files in the projects and also none of the other projects in the solution.
Edit:
I use VCL (https://github.com/vectorclass/version2) but CppCheck fails immediately and then doesn't check anything anymore.
It comes with this error message:
Severity : error
Line : 40
Id : preprocessorErrorDirective
Summary : #error Please compile for the SSE2 instruction set or higher
How do I let CppCheck check my solution?
Last edit: Sander Bouwhuis 2022-01-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Should I remove the VCL library directory from the files to check?
Edit:
I tried removing the VCL library from being checked with the 'Warning options/Exclude source files/Exclude folder' option, but it STILL checks the VCL directory and still fails.
I include the VCL header as one of the first includes in my top level header, so it gets included always. I cannot comment out the #include because then my projects can't compile at all anymore.
Last edit: Sander Bouwhuis 2022-01-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When you parse the .vcxproj files you have to look for this setting (SSE2 example):
Thanks! I will look into this.
Alternatively, is there a #define I can set in my code so that CppCheck knows which instruction set to use?
maybe that is a quick workaround.
another workaround is to specify the paths/defines manually. If you run analysis then at the bottom there is a tab "Analysis log". If you click there you can see all include paths and defines that are used in the analysis. If you configure those and add SSE2 it would work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't see where I can set any defines.
I checked 'File/Edit project file' and then the Analysis tab, but I don't see where I can add SSE2 as a define.
Also, I checked the 'Paths and Defines' tab, but when I select my .sln file the other controls become read-only.
Last edit: Sander Bouwhuis 2022-01-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes you need to remove the .sln file to be able to configure defines manually.. so it's not a very nice workaround.
The project import should work better now. Do you use windows? Can you try if the nightly build works better? https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml
Build 653 will be built in ~3 hours. When that is finished you can click on it. And then you can download a nightly build either:
* the "deploy" artifact is a zip file with all the files. You can unpack and run cppcheck from the unpacked folder. No installation.
* the "installer" artifact contains a windows installer.
Please note.. it might still be unstable. We are trying to make it stable right now so we can release it asap.
Let us know if you have any problems.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If there is a #include the cppcheck preprocessor will try to include the file even if the folder is excluded. By design.
I suggest that you suppress warnings in these folders. Click on "Add suppression" button in the GUI and specify filename "E:/Development/Dms v6.2.0 head/2022/Classes/Vcl/*" and leave the other fields empty I think that will work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to use CppCheck on a Visual Studio solution. But, when I use the 'Analyze/Files...' menu option and select the .sln file, it checks only 1 included directory and none of the files in the projects and also none of the other projects in the solution.
Edit:
I use VCL (https://github.com/vectorclass/version2) but CppCheck fails immediately and then doesn't check anything anymore.
It comes with this error message:
Severity : error
Line : 40
Id : preprocessorErrorDirective
Summary : #error Please compile for the SSE2 instruction set or higher
How do I let CppCheck check my solution?
Last edit: Sander Bouwhuis 2022-01-14
File/New Project File...
Import Project : Select your Visual Studio solution.
The same result. I even selected the following libraries in hopes the VCL library would be recognized:
microsoft_sal
vcl
windows
But, alas (see screenshot):
https://imgur.com/a/LBx1nwO
Should I remove the VCL library directory from the files to check?
Edit:
I tried removing the VCL library from being checked with the 'Warning options/Exclude source files/Exclude folder' option, but it STILL checks the VCL directory and still fails.
I include the VCL header as one of the first includes in my top level header, so it gets included always. I cannot comment out the #include because then my projects can't compile at all anymore.
Last edit: Sander Bouwhuis 2022-01-18
please unselect VCL because that is for "Visual Component Library".
You could try adding
-DINSTRSET=2
or higher to your command line.That may indeed circumvent the problem. Can you tell me where to set that in the GUI?
I have never used the GUI, but maybe this is helpful: https://github.com/danmar/cppcheck/blob/main/gui/projectfile.txt
could somebody give any feedback about if these macros are usually defined in visual studio?
SSE4_2
SSE4_1
SSSE3
SSE3
SSE2
SSE
x86_64
should we define some of these when a visual studio project is imported?
maybe the x86_64 should be defined if platform is win64.
I wonder if you can add this somewhere in your code:
When you compile you should get a compiler warning..
It would be super if you could determine how the pointed out macro is defined.
I don't see them, and they're not in this list either: https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
Although there are some
__AVX*__
macros,When you parse the .vcxproj files you have to look for this setting (SSE2 example):
The values are one of the following:
SSE : StreamingSIMDExtensions
SSE2 : StreamingSIMDExtensions2
AVX : AdvancedVectorExtensions
AVX2 : AdvancedVectorExtensions2
AVX512 : AdvancedVectorExtensions512
When there is no setting in the vcxproj file, it means SSE2 will be used.
Alternatively, is there a #define I can set in my code so that CppCheck knows which instruction set to use?
or maybe
Last edit: Sander Bouwhuis 2022-01-18
Thanks! I will look into this.
maybe that is a quick workaround.
another workaround is to specify the paths/defines manually. If you run analysis then at the bottom there is a tab "Analysis log". If you click there you can see all include paths and defines that are used in the analysis. If you configure those and add SSE2 it would work.
I don't see where I can set any defines.
I checked 'File/Edit project file' and then the Analysis tab, but I don't see where I can add SSE2 as a define.
Also, I checked the 'Paths and Defines' tab, but when I select my .sln file the other controls become read-only.
Last edit: Sander Bouwhuis 2022-01-19
yes you need to remove the .sln file to be able to configure defines manually.. so it's not a very nice workaround.
The project import should work better now. Do you use windows? Can you try if the nightly build works better?
https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml
Build 653 will be built in ~3 hours. When that is finished you can click on it. And then you can download a nightly build either:
* the "deploy" artifact is a zip file with all the files. You can unpack and run cppcheck from the unpacked folder. No installation.
* the "installer" artifact contains a windows installer.
Please note.. it might still be unstable. We are trying to make it stable right now so we can release it asap.
Let us know if you have any problems.
Thanks Daniel, it definitely gets farther now. But, it still checks files I've explicitely asked NOT to check.
Screenshot : https://flic.kr/p/2mYmxCx
If there is a #include the cppcheck preprocessor will try to include the file even if the folder is excluded. By design.
I suggest that you suppress warnings in these folders. Click on "Add suppression" button in the GUI and specify filename "E:/Development/Dms v6.2.0 head/2022/Classes/Vcl/*" and leave the other fields empty I think that will work.
Yes, that worked. Thanks a bunch!
My solution has 15 projects, but only 1 is checked. Why aren't all the projects checked?
Only the project named 'Classes' is checked.
Last edit: Sander Bouwhuis 2022-01-23