Skip to main content

IAR Embedded Workbench for Arm 9.70.x

Getting started analyzing using C-STAT

In this section:
  1. Before you perform a static analysis, make sure your project builds without errors. For information about how to build a project, see Building a project.

  2. Choose Project>Options and select the Static Analysis category. On the C-STAT Static Analysis page, click Select C-STAT Checks.

  3. In the Select C-STAT Checks dialog box, select the packages of checks you want to use. For example STDCHECKS.

    SelectPackagesOfCtatChecks_2.png
  4. For each package, select groups of checks or individual checks:

    SelectCStatChecks_1.png

    For information about a specific check, select it and press F1 to open the context-sensitive online help system.

    When you have made your settings, click OK and then OK again.

  5. To perform an analysis, make sure the project is active and execute one of these steps:

    • To analyze your project, select the project in the Workspace window and choose Project>C-STAT Static Analysis>Analyze Project.

    • To analyze one or more individual files, select the file(s) in the Workspace window and choose Project>C-STAT Static Analysis>Analyze File(s).

    Alternatively, use the corresponding commands on the context menu in the Workspace window instead.

  6. The result of the performed analysis is listed in the C-STAT Messages window.

    CStatAnalyzeResuts_1.png

    For information about a specific check, search for it in the help system.

    For reference information, see C-STAT Messages window.

    Note

    If there are any problems when analyzing, the Build Log window displays detailed information.

  7. Double-click a C-STAT message to view the corresponding source code in the editor window:

    CStatMessageSource_1.png

    Point at a message with the mouse pointer to get tooltip information about which check that caused the message.

  8. Correct the error and click the next message in the C-STAT Messages window. Continue until all messages have been processed.

    Note

    C-STAT has a predefined macro, __CSTAT__, that you can use to explicitly include or exclude specific parts of source code from the analysis, see __CSTAT__. There are also specific C-STAT pragma directives that suppress one or more checks for selected source lines, see Descriptions of compiler extensions for C-STAT.