Menu

A way to promote preprocessorErrorDirective to error?

2023-08-11
2023-08-11
  • Samuel Poláček

    I have observed that --project=compile_commands.json --force is able to identify more issues than --project=compile_commands.json (without --force) . That sound logical. The problem is that the issues that are identified in the first case and not in the second case are in no way inside #ifdef or #ifndef. The difference seems to stem from failed preprocessing of a third party header, which, of course, I have suppressed (with something like --suppress=*:*/3rdparty/*) and I could not see that Cppcheck hit the #error directive and bailed out, which has its consequences. In my case Cppcheck failed to identify problems with usage of types defined in the header where it hit the #error directive.

    Basically, in my case, a header is not able to figure out which platform and endianness it is running on so I need to pass some additional defines to Cppcheck so no #error directives are hit. Hitting an #error directive is basically a failed compilation.

    I am not sure whether Cppcheck should just ignore such configuration or whether it should fail so a user is forced to narrow configurations with -D and -U. I can see why its is better for Cppcheck to just continue in such a case and that the behavior, as is, is fine.

    Taking that into account, I think that I would like to run a Cppcheck healthcheck first, which would report only a selected subset of warnings, which leads me to the following question - is there a way to --suppress all warnings except for preprocessorErrorDirective? Combined with --error-exitcode will yield just what I need.

     

    Last edit: Samuel Poláček 2023-08-11
  • CHR

    CHR - 2023-08-11
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.