Reputation: 17138
I've tried to do static code analysis on my project which basically is made up from .hpp files as everthing is "templated" there, but unfortunately I'm getting info from PSV-Studio that header files cannot be processed. That seems bit strange. In modern C++ templates are everywhere and AFAIC they are mostly placed in header files. Am I missing something? Is there a way to set-up PVS-Studio to do analysis on header files?
Upvotes: 1
Views: 872
Reputation: 291
PVS-Studio does support analysis of "templated" code, even if it is not instantiated.
However, PVS-Studio needs the file to be preprocessed to analyze it, i.e. all #includes and macros should be expanded before the analysis. To accomplish this, PVS-Studio needs a compilable file, i.e. the file that is passed to the compiler along with the necessary compiler flags (defines, includes, etc.). Having just one header file is insufficient, as PVS-Studio will not have enough information to preprocess it correctly.
The "Unable to start analysis on this file" is most likely a V008 error, meaning that the preprocessor exited with a non-zer code, which means that the file you are trying to analyze is non-compilable. Usually, PVS-Studio will also output the cause of the error (stdErr from the preprocessor process) as the next message. You can read about it in more detail here.
Upvotes: 2