Menu

--addon=misra: Variable 'std' is unknown

mcandre
2024-08-06
2024-08-18
  • mcandre

    mcandre - 2024-08-06

    Hi,

    I am exploring securing my C++ projects with MISRA. However, when I use the --addon=misra flag, then cppcheck suddenly generates an extraordinary amount of spurious complaints that it is unaware of the std namespace, of nullptr, staticcast, and plenty of other standard, modern C++ elements.

    Tried supplying a --std=c++17 flag to remind cppcheck that the project is targeting the C++17 standard , but still getting the same behavior.

    Weird, cppcheck -h reports that it only knows of the C89 and C99 standards, not C11, C17, C23, C++11, C++17, C++23, etc.

    cppcheck does not appear to validate, short-circuit, or exit non-zero when an unknown language standard value is supplied.

    I'm using cppcheck 2.14.2.

    Is the MISRA addon targeting an old version of C++, or perhaps only pure C code?

    Is there a misra config JSON setup to work around this problem?

     

    Last edit: mcandre 2024-08-06
  • Daniel Marjamäki

    The misra.py is only for pure C code. You can run it on C++ code but it will not handle it well.

    If you would like to try out Misra C++ you can look at Cppcheck Premium it's possible to try it out for free..

    cppcheck does not appear to validate, short-circuit, or exit non-zero when an unknown language standard value is supplied.

    ouch that is not good. I can reproduce. I have created ticket https://trac.cppcheck.net/ticket/13021

     

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.