Independent learning for embedded-systems engineersHardware · Firmware · Software
TEA-307STANDARDS & GUIDANCESAFE CODING

MISRA C and C++ guidance

Use language restrictions, analysis and disciplined deviation to reduce ambiguity and defect risk in safety-related C and C++ software.

After this module, you should be able to:

  • Explain what MISRA guidance can and cannot achieve
  • Plan a project-specific compliance approach
  • Use static analysis and review together
  • Control deviations with technical justification
01 / INTENT

MISRA guidance reduces avoidable language risk.

C and C++ give embedded developers powerful low-level control but include behaviours and constructs that are easy to misunderstand, implementation-dependent or difficult to analyse. MISRA guidance defines disciplined subsets and practices for critical systems.

Compliance is a project activity, not simply a tool report. The team must identify the applicable guideline edition and amendments, define scope, select analysis methods, address or deviate violations and retain a credible compliance record.

LANGUAGEReduce ambiguitySafer subsets and disciplined constructs
ANALYSISFind violationsCompiler, static analysis and human review
GOVERNANCEControl exceptionsProcess, deviation rationale and evidence
Zero warnings is not the same as safe software.Rules reduce particular language risks; architecture, requirements, concurrency, timing, security and verification remain essential.
02 / FRAMEWORK

Translate the framework into controlled engineering work.

AreaQuestionTypical evidence
Compliance planWhich guidelines, scope, tools and process apply?Guideline compliance plan
Compiler controlWhich implementation-defined behaviour and options are permitted?Compiler and language configuration
AnalysisHow will decidable and undecidable guidance be checked?Static-analysis and review strategy
DeviationWhen may a rule be violated and who approves it?Deviation procedure and records
ReportingHow is final compliance and residual non-compliance shown?Compliance summary

Apply the current controlled source

This module is an orientation. Confirm the applicable edition, amendments, adopted regional version, contractual commitments and sector-specific interpretations before defining compliance.

03 / APPLICATION

Use a risk-based application sequence.

  1. 1. Select the applicable MISRA publication, amendments and language version
  2. 2. Define translation units, generated code, third-party code and exclusions
  3. 3. Configure compiler warnings and qualified or validated analysis tools
  4. 4. Analyse continuously; resolve findings close to introduction
  5. 5. For necessary deviations, record circumstance, risk, evidence and approval
  6. 6. Report compliance for the released baseline and retain tool configurations

Worked application: memory-mapped register access

A low-level driver may need a construct that conflicts with general guidance. The team isolates it in one reviewed abstraction, documents the hardware necessity, analyses undefined-behaviour risk, verifies compiler behaviour and approves a narrow deviation rather than normalising the exception across the codebase.

04 / EVIDENCE

Build evidence that explains the reasoning.

Compliance plan

Guideline version, scope, process, tools and roles.

Tool configuration

Rules, compiler options, suppressions and versions.

Analysis results

Findings linked to controlled source revisions.

Review records

Human assessment of guidance not fully automatable.

Deviation records

Rule, location, rationale, risk and approval.

Compliance summary

Released baseline, status and justified exceptions.

Common failure patterns

Tool badge compliance

One scanner is assumed to cover every guideline.

Suppression without rationale

Warnings disappear without engineering assessment.

Late clean-up

Thousands of findings are deferred until release.

Generated-code blind spot

Unreviewed generation and integration undermine the claim.

05 / REFERENCES

Further learning

KEY TAKEAWAY

Use the standard to strengthen decisions, not decorate them.

Make scope, tailoring, responsibilities, technical reasoning and objective evidence explicit—and always work from the current authorised text.