Is there a way to pass custom file extensions to Cppcheck? For example, *.pc
.
Asked
Active
Viewed 1,381 times
0
-
Should this be tagged `c++` instead of `c`? – Fiddling Bits Aug 11 '14 at 11:19
-
@FiddlingBits: cppcheck can work with C code too. – sharptooth Aug 11 '14 at 13:17
-
@sharptooth: so it appears. Can you answer the question as well? ;-) – Jongware Aug 11 '14 at 18:14
-
I think it is not possible (but i'm not sure), maybe you can write a simple script that copies files to correct extension and exec cppcheck and remove files. – ocirocir Aug 11 '14 at 19:15
1 Answers
4
sure. cppcheck will check any file that you give it.
check the file xyz.pc:
cppcheck xyz.pc
check all files with extension pc in folder srcfolder (this at least works in linux):
cppcheck srcfolder/*.pc
the --file-list flag may also be useful. you could generate the list of files that you want to check using an arbitrary script. and then run cppcheck on that file list.
cppcheck --file-list=files.txt

Daniel Marjamäki
- 2,907
- 15
- 16
-
Thanks! Ended up writing a script to gather all the file types into a list, and pass that in. – James Aug 12 '14 at 10:33
-
@Daniel Marjamäki Would it be possible to add a command line option to specify extensions to look at ? For instance, I use .cxx, .hxx and .inl for my C++ projects. I would rather not have to specify those files or create an alias for cppcheck that is cppcheck --file-list=
. – ghlecl Apr 14 '18 at 16:49 -
1not sure.. I am not _against_ it. It's just that we are pretty careful about adding command line arguments and this is not a common feature request. The .cxx is handled already. I would recommend that you dont add headers (.hxx) it is better for the analysis if you include those and check the source files. I do not know what .inl is, is that included files also? – Daniel Marjamäki Apr 15 '18 at 20:43
-
is there any way to add this functionality to a powershell script so that it auto runs rather than typing it in a terminal? – NeonFire May 21 '21 at 19:49