Embedded
Documentation

Version Latest

Static analysis, MISRA C and stack usage

Running Cppcheck with its MISRA C:2012 addon from the Editor, rule texts, recording deviations, the compliance summary, coding standards checks on save, and per-function stack usage from GCC.

Static analysis runs Cppcheck with its MISRA C:2012 addon and puts every finding in Problems at its line. Cppcheck is the analyser the module drives today; the vendor analysers are listed on What's next.

Verification state: unit-tested on Cppcheck XML output fixtures. The integration test against a real Cppcheck exists and has not run in a verified audit; no Cppcheck version is verified. On the Embedded Linux side, Cppcheck 2.13.0 with the MISRA addon has run on Linux (see Embedded Linux).

Requirements

  • Cppcheck 2.10 or newer, found on PATH or through neuralInverse.embedded.paths.cppcheck.
  • Python 3 that Cppcheck can run, for the MISRA addon.
  • For guideline headlines and categories: a MISRA C:2012 rule texts file from your own licensed copy of MISRA C:2012. The texts are copyrighted by MISRA, so none ship with the Editor.

Run it

CommandWhat it does
Run Static Analysis (Cppcheck, MISRA C:2012)Analyses the project, with the compile commands of the active build
Run Static Analysis on Current FileAnalyses the open file
Show MISRA C:2012 Compliance SummaryThe summary of the last project run: tool and version, date, violations per guideline, recorded deviations
Clear Static Analysis ResultsRemoves the findings from Problems

Cppcheck MISRA C:2012 findings in Problems and the compliance summary of the run.Cppcheck MISRA C:2012 findings in Problems and the compliance summary of the run.

Set neuralInverse.embedded.analysis.onSave to true to analyse each C or C++ source file of the project when it is saved.

Settings

SettingDefaultMeaning
neuralInverse.embedded.analysis.misratrueCheck the MISRA C:2012 guidelines (with amendments 1 and 2) that Cppcheck's addon supports
neuralInverse.embedded.analysis.misraRuleTextsemptyYour rule texts file, in the format the addon reads (Appendix A as text), absolute or relative to the folder of CMakePresets.json. With it, mandatory findings show as errors, required as warnings, advisory as information
neuralInverse.embedded.analysis.checkswarning, style, performance, portabilityCppcheck check groups besides its error checks, which always run
neuralInverse.embedded.analysis.suppressionsFileemptyYour approved deviations (below)
neuralInverse.embedded.analysis.exclude**/third_party/**Globs of files to skip, such as vendored code
neuralInverse.embedded.analysis.onSavefalseAnalyse on save

Without a rule texts file, guideline categories are unknown and the summary says so.

Record approved deviations

Write deviations in a Cppcheck suppressions file and name it in neuralInverse.embedded.analysis.suppressionsFile. One id[:file[:line]] per line, with the rationale in # comments above it:

# Deviation D-012, approved by the safety lead: the DMA descriptor cast is required by the hardware.
misra-c2012-11.5:drivers/dma.c

Deviations in the suppressions file are listed in the compliance summary. cppcheck-suppress comments in the source also work, but are not listed there.

What the summary does and does not show

Cppcheck's MISRA addon does not check every guideline, and some guidelines cannot be decided by any tool. A guideline without violations in the summary is not shown to be complied with: record how each unchecked guideline is met before claiming compliance. The summary is evidence toward a MISRA C:2012 compliance argument; it is not a compliance claim.

Coding standards on save

Three checks run on save, with findings in Problems under the source Neural Inverse Embedded:

CheckSettingDefault
Every C, header and assembly file starts with your organisation's header ({year} stands for a year or range)neuralInverse.embedded.standards.requiredHeaderEmpty: not checked
No run-time allocation (malloc, calloc, realloc, free, alloca, pvPortMalloc, vPortFree and similar) in the folders listedneuralInverse.embedded.standards.noDynamicAllocationDirectoriesEmpty: no folder checked
No #pragma once; guard headers with #ifndef, #define and #endifAlways on

neuralInverse.embedded.standards.exclude (default third_party/**, build/**, out/**) lists files these checks skip.

Coding standards findings in Problems: a missing copyright header, dynamic allocation in a driver, and #pragma once in a header.Coding standards findings in Problems: a missing copyright header, dynamic allocation in a driver, and #pragma once in a header.

State: unit-tested; the integration test exists and did not run in the audit.

Stack usage

Build with GCC's -fstack-usage. The module reads the .su files and puts every function whose stack frame has no bound (a variable-length array or alloca) in Problems. Per-function frames also appear in the Firmware Memory editor.

This covers per-function frames from GCC, as STM32CubeIDE's Static Stack Analyzer does for each function. State: unit-tested on .su fixtures; GCC output from a real build is not verified.

Last reviewed 18 October 2026View as Markdown

Static analysis, MISRA C and stack usage · Docs · Neural Inverse