Menu

Supported devices to perform cppCheck and adding support of new devices

2024-05-14
2024-06-14
  • Parth Mehta

    Parth Mehta - 2024-05-14

    Hi,

    I would like to know about which devices are supported with cppCheck.
    Also how to add support of new devices?

    I am listing few observations which i noticed during cppCheck exploration.

    -> I tried to perform cppCheck on firmware of renesas controller (R7FA4M3AF Family, firmware compiled with e2studio). In that i selected .project file for the same but countered so many errors during that.

    -> Tried with SAMR30 firmware (ATSAMR30E18A, Firmware compiled with Microchip studio IDE). I followed the same steps to perform cppCheck but again i encountered so many errors.

    -> Tried with PIC24F firmware (PIC24F family, Firmware built with MPLAB X IDE) and with this project file, i was able to generate cppCheck report successfully).

    So i was wondering if there is only perticular devices supported with cppCheck and if there is any way to add support of new devices.

    Thanks,
    Parth

     

    Last edit: Parth Mehta 2024-05-14
  • Andrew C Aitchison

    cppcheck checks source code, so the better question might be which IDEs does it support, but really all it needs is the source file, so it should be possible for it to check any C or C++ code in a filesystem (scanning code inside a database might not be posssible).

    What sort of errors are you getting ?

    From the sound of it, you are not getting reports from cppcheck. If the issue is instead that cppcheck reports many problems with the code, it may be that cppcheck is checking against a different version of the language, and different system libraries from the IDE.

     
  • Parth Mehta

    Parth Mehta - 2024-05-21

    Thank you for your response.

    I have a few more questions that I hope you can assist me with:

    1) I noticed that CppCheck does not generate any errors or warnings if it cannot access a standard library file. For example, when performing incorrect operations on strings, no errors are shown because it cannot access the "string.h" library. How can I ensure that standard libraries are supported in my source code or how to add standard libs path in my source code?

    Have attached the capture for the same!

    2) I have organized my source code with all C files in a 'source' folder and all header files in a 'header' folder. However, when I run CppCheck, it does not seem to access the libraries in the 'header' folder. How can I properly link the source files with the header files?

    Thanks,
    Parth

     

    Last edit: Parth Mehta 2024-05-21
    • Daniel Marjamäki

      We don't warn about that. Your compiler warns about strcpy(a,b,5); . The syntax errors are not very interesting for Cppcheck.

      On the other hand not all compilers warns about some code like:

      #include <string.h>
      void foo(void) {
          char buf[5];
          strcpy(buf, "hello world!");
      }
      
       
  • Parth Mehta

    Parth Mehta - 2024-05-22

    Thank you for your quick response.

    Is there a way or a plugin available to integrate CppCheck with an e2studio/Eclipse-based project or for microchip studio based project that can check for CppCheck errors during code compilation? If so, could you please provide the procedure for integrating it?

    Thank you,
    Parth

     

    Last edit: Parth Mehta 2024-05-22
  • Daniel Marjamäki

    Try this.

    In Eclipse this works:

    1. Open "Help" Menu
    2. Open "Eclipse Marketplace..."
    3. Search for "Cppcheclipse"
    4. Install the Cppcheclipse plugin

    Look through the project settings and configure Cppcheclipse.

     
  • Parth Mehta

    Parth Mehta - 2024-05-23

    I tried it, but it didn't generated cppCheck report directly when i compiled the code in IDE.
    Do i need to perform anything else for the same?

    Thanks,
    Parth

     

    Last edit: Parth Mehta 2024-05-23
  • Parth Mehta

    Parth Mehta - 2024-05-29

    Hi,

    I tried to generate cppCheck report directly when i compiled the code in eclipse based IDE, but no report was generated.
    Do i need to perform anything else for the same?

    Your insights would be helpful to me.

    Thanks,
    Parth

     

    Last edit: Parth Mehta 2024-05-29
  • Daniel Marjamäki

    example settings: settings.png
    check the checkbox "Check for coding style issues"

    In the treeview to the left you can see that "cppcheclipse" has sub items. One of its sub items is "Build". I suggest you click on that and then check the checkbox "Run on build"

    Now you can either run cppcheck by:
    * build your code. Project => Build All.
    * right click on the source file, in the popup menu choose "Cppcheck" and then "Run Cppcheck"

    Warnings are shown in the "Problems tab" and are also marked in the editor. As you can see in the eclipse.png screenshot. Line 4 is marked in the editor because there is a cppcheck warning on that line.

     

    Last edit: Daniel Marjamäki 2024-05-29
  • Parth Mehta

    Parth Mehta - 2024-06-03

    I will try it in my setup.

    Thank you,
    Parth

     

    Last edit: Parth Mehta 2024-06-03
  • Parth Mehta

    Parth Mehta - 2024-06-05

    Thank you so much! it worked for me on e2studio.

    Now i am trying with microchip studio as i would like to integrate cppCheck in all of my projects.
    But when i tried to download & install the plugin from microchip studio, i faced an issue in downloading. I am sharing that log here, any insights on that would greatly help me.

    Logs :

    05-06-2024 11:35:49 - Microsoft VSIX Installer
    05-06-2024 11:35:49 - -------------------------------------------
    05-06-2024 11:35:49 - Initializing Install...
    05-06-2024 11:35:49 - Extension Details...
    05-06-2024 11:35:49 - Identifier : 439f966e-9569-417b-adc9-339c8b276997
    05-06-2024 11:35:49 - Name : CppCheck Integrator (Beta)
    05-06-2024 11:35:49 - Author : Atmel
    05-06-2024 11:35:49 - Version : 1.0.0.9
    05-06-2024 11:35:49 - Description : The extension integerates CppCheck with Atmel Studio and provides a quick and easy way to perform a static code analysis.
    05-06-2024 11:35:49 - Locale : en-US
    05-06-2024 11:35:49 - MoreInfoURL : http://cppcheck.sourceforge.net/
    05-06-2024 11:35:49 - InstalledByMSI : False
    05-06-2024 11:35:49 - SupportedFrameworkVersionRange : [4.0]
    05-06-2024 11:35:49 -
    05-06-2024 11:35:49 - Supported Products :
    05-06-2024 11:35:49 - AtmelStudio
    05-06-2024 11:35:49 - Version : [6.0]
    05-06-2024 11:35:49 -
    05-06-2024 11:35:49 - References :
    05-06-2024 11:35:49 -
    05-06-2024 11:35:49 - Searching for applicable products...
    05-06-2024 11:35:50 - Found installed product - Global Location
    05-06-2024 11:35:50 - Found installed product - AtmelStudio
    05-06-2024 11:35:50 - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
    at VSIXInstaller.App.InitializeInstall(Boolean isRepairSupported)
    at VSIXInstaller.App.InitializeInstall()
    at System.Threading.Tasks.Task.InnerInvoke()
    at System.Threading.Tasks.Task.Execute()

    Thanks,
    Parth

     

    Last edit: Parth Mehta 2024-06-05
    • Daniel Marjamäki

      The “CppCheck Integrator (Beta)” extension was made by a former Microchip employee in India.

      It was created for Atmel Studio 6.0 which is based on Visual Studio Isolated Shell 2010.

      To make it work on Microchip Studio 7.0 the extension must be updated to say that it can be used with version 7.0 (based on Visual Studio Isolated Shell 2015).

      1. Download extension from Microchip gallery
        https://gallery.microchip.com/
        Search for CppCheck Integrator (Beta) https://gallery.microchip.com/packages/439f966e-9569-417b-adc9-339c8b276997/
        Download cppcheck_integrator_(beta).1.0.0.9.vsix

      2. The *.vsix is actually a zip file. Unzip the file.

      3. Open the extension.vsixmanifest file in an editor.
        Update line number 15:
        <IsolatedShell Version="6.0">AtmelStudio</IsolatedShell>
        to:
        <IsolatedShell Version="7.0">AtmelStudio</IsolatedShell>

      4. Zip the folder back again with the updated extension.vsixmanifest file. (NB! Do not zip with an added folder level.)

      5. Rename cppcheck_integrator_(beta).1.0.0.9.zip back to
      6. Right click on cppcheck_integrator_(beta).1.0.0.9.vsix and select: Open with... ->Chose Another app:
        C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\VSIXInstaller.exe

      7. Install

       

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.