Menu

How to use cppcheck with a project from MPLAB?

Mplabtest
2023-11-28
2023-12-05
  • Mplabtest

    Mplabtest - 2023-11-28

    Hi All,

    I would like to use cppcheck with a project from MPLAB. It doesn't have to be integrated or automated. Can someone please let me know how to import a MPLAB project into cppcheck?

     
  • Daniel Marjamäki

    I am not sure what the best approach is.

    What happens if you just provide the path to the source code?

    cppcheck --enable=style c:\path\to\your\project
    
     
    • Mplabtest

      Mplabtest - 2023-11-30

      Hi Daniel,

      Thank you for your quick reply, I appreciate it. I was able to import the project and use Cppcheck.

      The information severity that were reported were libraries not found, similar to the message: "Include file: "xc.h" not found". The libraries reside in a folder the compiler accesses on the installation, standard header files. They are part of the C libraries.

      Can you let us know if there is a way to address it ?

       
      • Daniel Marjamäki

        I would not recommend that you provide the paths to standard C headers such as stdio.h because cppcheck has better internal knowledge about the standard functions.

        If you want to provide the path to xc.h you can use -Ic:\path. If you do this it's probably a good idea to provide -D.. flags also that match your compiler.

        Please note that "Include file: "xc.h" not found" is not a critical error. Cppcheck analysis continues and various bugs can be found anyway.. for a compiler that is a critical problem but in Cppcheck static analysis it's not. Personally I often don't provide all the paths to headers. You can try out how it works with all the paths and without all the paths and use the approach that will work best..

         
        • Mplabtest

          Mplabtest - 2023-12-04

          Hi Daniel,

          Thank you. Can you please let me know how to exclude paths to the C headers?

           
          • Daniel Marjamäki

            Just don't add the -I that points at stdio.h

             

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.