MISRA C — Safe Coding for Embedded Systems
MISRA C is a set of coding guidelines developed by the Motor Industry Software Reliability Association (MISRA) to ensure safety, security, and reliability of C code in embedded systems. Originally created for the automotive industry, MISRA C is now the de facto standard across aerospace, medical devices, industrial control, rail, and any domain where software failure has safety or security consequences.
MISRA C:2023 and MISRA C:2025
The 2023 edition (MISRA C:2012 Third Edition, Second Revision) consolidates MISRA C:2012 with Amendments 1–4 and Technical Corrigenda 1–2 into a single document. MISRA C:2025, an incremental update published in March 2025, is the current edition. Key 2023 updates include:
| Update | Description |
|---|---|
| C11/C18 support | Guidelines for _Generic, _Noreturn, _Alignas, atomics and threads |
| Concurrency rules | New guidelines for multithreading and atomic operations — critical for RTOS-based embedded |
| Security focus | Published coverage mappings against CERT C and ISO/IEC 17961 (a CWE mapping was added with MISRA C:2025) |
| Unified document | All amendments and corrigenda merged into one specification |
Guideline Classification
| Category | Meaning | Deviation Allowed? |
|---|---|---|
| Mandatory | Must be followed — no exceptions | ❌ Never |
| Required | Must be followed unless formally deviated | ✅ With documented rationale |
| Advisory | Recommended best practice | ✅ No formal deviation needed |
Guidelines are further classified as Rules (precisely defined, tool-checkable) or Directives (broader, require engineering judgment).
What MISRA C Prevents
Common C-language pitfalls that MISRA C guards against:
- Undefined behavior — Signed integer overflow, uninitialized variables, null pointer dereference
- Implementation-defined behavior — Bit-field ordering, char signedness, struct padding
- Dangerous constructs —
goto,setjmp/longjmp, unions for type-punning, recursive functions - Security vulnerabilities — Buffer overflows, format string attacks, integer truncation
- Concurrency bugs — Data races, non-atomic operations on shared variables
Compliance in Practice
| Aspect | Approach |
|---|---|
| Static analysis tools | PC-lint, Polyspace, Coverity, Parasoft, LDRA, QA-C |
| CI/CD integration | Automated MISRA checking on every commit |
| Deviation process | Formal deviation record with safety impact analysis |
| Compliance matrix | Mapping of MISRA rules to project rules with violation tracking |
MISRA C + Functional Safety Standards
MISRA C compliance is referenced or implied by major safety standards:
| Standard | Domain | MISRA Requirement |
|---|---|---|
| ISO 26262 | Automotive | Requires coding guidelines; cites MISRA C as an example for C |
| IEC 61508 | Industrial | Recommends restricted C subset |
| DO-178C | Aerospace | Coding standards required (MISRA commonly used) |
| IEC 62304 | Medical | Requires documented coding standards |
| EN 50716 (supersedes EN 50128) | Railway | Recommends restricted language subset |
Related Terms
- CRA — The EU Cyber Resilience Act requires products to be designed and developed for appropriate cybersecurity but names no coding standard; MISRA C is one way to support this for C code.
- RTOS — MISRA C:2023’s new concurrency guidelines are essential for RTOS-based multi-threaded firmware.
All our embedded projects follow MISRA C guidelines with automated static analysis in CI/CD. See our Embedded Systems Development services.
Official References
- MISRA C — Guidelines for the Use of the C Language in Critical Systems — MISRA Consortium