0

I'm running CppCheck over some files containing CLI code. As the CLI portions of the file make use of '^)' characters, I'm trying to suppress the "false positive" syntaxError generated by CppCheck due to those characters.

Rather than using inline suppression commands, I have decided to create an XML suppression file to achieve my purpose.

Here is a snippet of the suppression file.

<?xml version="1.0"?> 
<suppressions>
    <suppress>
        <id>syntaxError</id> 
        <fileName>src/file1.c</fileName>
        <symbolName>^)</symbolName>
    </suppress>
        ...
</suppressions>

This is based off example shown by the CppCheck manual

<?xml version="1.0"?> 
<suppressions>
    <suppress>
       <id>uninitvar</id> 
       <fileName>src/file1.c</fileName>         
<      <lineNumber>10</lineNumber>      
       <symbolName>var</symbolName>
    </suppress>
</suppressions>

As you can see, I am trying to use the symbolName field to specify that all syntaxError due to ^) should be suppressed.

However, my suppression currently does not suppress any syntaxErrors.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    Is therre any reason why you post xml as pictures instead of text? It makes it impossible for anyone to copy and test it. It's also mentioned in the instruction for this site to _not_ do that. In this case, xml will count as code or data: From [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask): "_**DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question_" – Ted Lyngmo Apr 16 '21 at 19:43
  • Have you tried to exclude the error by line number? – Roxxorfreak Apr 18 '21 at 16:14
  • Does this answer your question? [How to suppress specific cases of syntaxError with CppCheck (Updated)](https://stackoverflow.com/questions/67134832/how-to-suppress-specific-cases-of-syntaxerror-with-cppcheck-updated) – arved Apr 19 '21 at 08:49
  • I would ideally like to try and accomplish the suppression using the suppression file approach. Adding suppression comments into the source file can clutter things up. It would be greatly appreciated if someone can share some information regarding how I could use the symbolName field to specify that I do not want CppCheck to flag the ^) characters as a syntaxError. Thanks!! – HeinzGuderian Apr 19 '21 at 18:30
  • It would be great if you could provide the actual error and as well as source code which causes it so it is easier to figure out what to do. Having such code would also help in fixing the actual issue. – Firewave Jan 09 '22 at 19:21

0 Answers0