MISRA C Coding Standards Summary
What is MISRA C?
MISRA C is a set of software development guidelines for the C programming language developed by the
Motor Industry Software Reliability Association (MISRA).
It is intended to facilitate code safety, portability, and reliability in embedded systems.
Key Highlights
- Versions: MISRA C:1998, MISRA C:2004, MISRA C:2012
- Rule Types: Mandatory, Required, Advisory
- Categories: Syntax, Type usage, Control structures, Functions, etc.
- Focus: Avoid undefined behavior, improve maintainability and reliability
Common MISRA C Rules
Example Rules:
1. Rule 1.1: The program shall contain only one 'main' function.
2. Rule 10.1: Operands shall not be of an inappropriate essential type.
3. Rule 11.4: A cast should not be performed between a pointer to object type and a different object type.
4. Rule 15.6: The 'default' label shall appear as the last label in a 'switch' statement.
Tools for MISRA Compliance
Static Analysis Tools for MISRA C Compliance:
- PC-lint / FlexeLint
MISRA C Coding Standards Summary
- Coverity
- LDRA Testbed
- Polyspace
- Klocwork
- Cppcheck (basic MISRA support)
Importance of MISRA C
Why MISRA C Matters:
- Reduces risk of run-time errors in safety-critical systems.
- Encourages defensive and portable programming practices.
- Helps meet certification standards like ISO 26262, DO-178C.