I am learning; and of course this static analyzer is a welcome part of that. It was great to learn CodeBlocks IDE had integrated cppcheck as a plugin to make things easy. I am working with the SFML library while learning c/c++ and making progressively more complex games to do that.
The project is win32, and it turns out SFML doesn't support win64. So, after using the cppcheck installer and running with CodeBlocks, cppcheck found that platform requirent as an error code in SFML, and only reported those parts of my project that were indepedent of SFML. (it found a nice redundancy in my code to clean up; and again, I'm learning) It skipped anything having to do with SFML beyond that (makes sense), but looked super helpful immediately.
So, okay, forget the win64 installer and compile cppcheck for win32, right? I download the source (open the .sln in VS) and compile for win32. Great! ... uh
I am unsure what the resulting compilation (cppcheck-core.dll, the cli folder, etc) should look like for use as a win32 setup (which I would then use CodeBlocks settings to point to the .exe for proper plugin use). It seems like I'm one step away from having a full check of my win32 c++ project.
In other words, I knew enough to get this far, and this step is new to me. (I have searched) What should a cppcheck win32 build folder/file structure look like? 'Much appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
you can check win32 code with a 64-bit cppcheck. Use --platform=win32A or --platform=win32W at the command line. And --library=windows might be a good idea also.
I recommand that you use --library=sfml also.
You can even use the win64 cppcheck to check linux code, embedded 16-bit code, etc..
cppcheck found that platform requirent as an error code in SFML
If you have something like:
#ifndefSOME_PLATFORM
#errorNotsomeplatform
#endif
And Cppcheck complains about that.. then the solution is to configure Cppcheck. You can use --platform to get proper types. But -D might be needed to get proper preprocessor macros.
If you have a visual studio solution I recommend that you use that:
cppcheck--project=yoursolution.sln
What should a cppcheck win32 build folder/file structure look like?
If you built with visual studio the exe is in cppcheck\bin\debug\cppcheck.exe
however I do not think that a 32-bit exe will solve your problems.
Last edit: Daniel Marjamäki 2020-05-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did use some command line configuration options. Namely: --platform-win32A and -D-_Win32=1, and it's that last one that I thought might get past the preprocessor macro issue. This is what I thought cppcheck would allow, so good to know I was on the right track. It is SFML that looks for _Win32 (and several other support OS, but not win 64) and else provides a #error, as you suggest. I didn't try --library-windows or --library-sfml.
This was the last combinations of command line configs I tried (used in CodeBlocks settings for the cppcheck plugin):--verbose --enable=all --enable=style --xml --language=c++ --std=c89 --platform=win32A --project-configuration=Release|Win32
I did build with visual studio, and I saw the .exe, so I pointed to it with CodeBlocks cppcheck plugin settings. This caused it to complain the cppcheck-core.dll was missing, so I naively moved the newly built .dll next to the newly built .exe (in /bin), hoping that would be it. No luck.
Yeah, the reason I was thinking the 32-bit exe was necessary is due to SFML. It auto-detects the OS and, since everything else is win32, I am making the assumption it's the win64 install of cppcheck that it's getting tripped up on.
Given this response, I will go back and try a few other combinations. I'll report back if something clicks, in case this can help someone else. (thanks again)
Last edit: Glenn Storm 2020-05-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ooooh, -D_WIN32 appears to be the magic phrase I was looking for. (I had just about every other combination, thank you)
I have a lot more to work on now. For those interested in the final 64-bit instal version settings for the CodeBlocks cppcheck plugin (for SFML), this is what I have at the moment that seems to work.
I am learning; and of course this static analyzer is a welcome part of that. It was great to learn CodeBlocks IDE had integrated cppcheck as a plugin to make things easy. I am working with the SFML library while learning c/c++ and making progressively more complex games to do that.
The project is win32, and it turns out SFML doesn't support win64. So, after using the cppcheck installer and running with CodeBlocks, cppcheck found that platform requirent as an error code in SFML, and only reported those parts of my project that were indepedent of SFML. (it found a nice redundancy in my code to clean up; and again, I'm learning) It skipped anything having to do with SFML beyond that (makes sense), but looked super helpful immediately.
So, okay, forget the win64 installer and compile cppcheck for win32, right? I download the source (open the .sln in VS) and compile for win32. Great! ... uh
I am unsure what the resulting compilation (cppcheck-core.dll, the cli folder, etc) should look like for use as a win32 setup (which I would then use CodeBlocks settings to point to the .exe for proper plugin use). It seems like I'm one step away from having a full check of my win32 c++ project.
In other words, I knew enough to get this far, and this step is new to me. (I have searched) What should a cppcheck win32 build folder/file structure look like? 'Much appreciated.
you can check win32 code with a 64-bit cppcheck. Use
--platform=win32A
or--platform=win32W
at the command line. And--library=windows
might be a good idea also.I recommand that you use
--library=sfml
also.You can even use the win64 cppcheck to check linux code, embedded 16-bit code, etc..
If you have something like:
And Cppcheck complains about that.. then the solution is to configure Cppcheck. You can use
--platform
to get proper types. But-D
might be needed to get proper preprocessor macros.If you have a visual studio solution I recommend that you use that:
If you built with visual studio the exe is in cppcheck\bin\debug\cppcheck.exe
however I do not think that a 32-bit exe will solve your problems.
Last edit: Daniel Marjamäki 2020-05-26
Thanks for the response, Daniel. I appreciate it.
I did use some command line configuration options. Namely:
--platform-win32A
and-D-_Win32=1
, and it's that last one that I thought might get past the preprocessor macro issue. This is what I thought cppcheck would allow, so good to know I was on the right track. It is SFML that looks for_Win32
(and several other support OS, but not win 64) and else provides a#error
, as you suggest. I didn't try--library-windows
or--library-sfml
.This is the preprocessor definition check that cppcheck stops on:
https://www.sfml-dev.org/documentation/2.5.1/Config_8hpp_source.php
(stops at line 104)
This was the last combinations of command line configs I tried (used in CodeBlocks settings for the cppcheck plugin):
--verbose --enable=all --enable=style --xml --language=c++ --std=c89 --platform=win32A --project-configuration=Release|Win32
I did build with visual studio, and I saw the .exe, so I pointed to it with CodeBlocks cppcheck plugin settings. This caused it to complain the cppcheck-core.dll was missing, so I naively moved the newly built .dll next to the newly built .exe (in /bin), hoping that would be it. No luck.
Yeah, the reason I was thinking the 32-bit exe was necessary is due to SFML. It auto-detects the OS and, since everything else is win32, I am making the assumption it's the win64 install of cppcheck that it's getting tripped up on.
Given this response, I will go back and try a few other combinations. I'll report back if something clicks, in case this can help someone else. (thanks again)
Last edit: Glenn Storm 2020-05-26
Please note that the macros are case sensitive. You should probably use
-D_WIN32
hmm.. for information I would have tried something like that also.
Ooooh,
-D_WIN32
appears to be the magic phrase I was looking for. (I had just about every other combination, thank you)I have a lot more to work on now. For those interested in the final 64-bit instal version settings for the CodeBlocks cppcheck plugin (for SFML), this is what I have at the moment that seems to work.
--verbose --enable=all --enable=style --xml --language=c++ --std=c89 --platform=win32A --library=windows --library=sfml -D_WIN32
I'll report back if/when anything else comes up regarding this issue. Thank you again, Daniel.