Menu

SyntaxError False Positive

2021-08-18
2021-08-19
  • Mike Banducci

    Mike Banducci - 2021-08-18

    I'm attempting to run cppcheck 2.5 on a project that includes some vendor code, and I've found the the following enum causes a syntax error:

    typedef enum
    {
      SUCCESS = 0,
      ERROR = !SUCCESS
    } ErrorStatus;
    

    I confirmed by making a .cpp file (attached) containing only that enum and analyzing it independent of any other code:

    [test.cpp:3] (error) syntax error: 0 = [syntaxError]

     
  • CHR

    CHR - 2021-08-18

    Are you on Windows? There is a #define ERROR in wingdi.h, which is also part of cppcheck's windows.cfg. Maybe passing -UERROR would help?

     
  • Mike Banducci

    Mike Banducci - 2021-08-18

    I'm running cppcheck on windows, but I'm analyzing an ARM codebase and have no libraries checked in the project configuration.

    Adding ERROR to the undefines list does appear to fix the issue, though it's not clear to me why I was picking up a #define from outside my selected libraries, include dirs, and source dirs. Is there a misconfiguration on my end?

    Thank you!

     
  • CHR

    CHR - 2021-08-19

    The default platform is the one you're running on. You can specify a different one using --platformhttps://linux.die.net/man/1/cppcheck

     

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.