Learn MISRA-C-AVIONICS with Real Code Examples
Updated Nov 27, 2025
Explain
MISRA C defines a subset of C with mandatory, required, and advisory rules to avoid unsafe constructs.
It focuses on eliminating undefined, unspecified, and implementation-defined behaviors.
Widely adopted in aerospace, automotive, and defense systems for safety certification.
Supports static analysis and code review compliance processes.
Facilitates maintainable and portable code across compilers and platforms.
Core Features
Restrictions on dynamic memory allocation
Prohibition of dangerous constructs (goto, setjmp, recursion in certain contexts)
Type safety and strict conversions
Structured control flow and function usage guidelines
Portability and predictability enforcement across compilers
Basic Concepts Overview
Mandatory Rules - must be strictly enforced
Required Rules - should be enforced unless justified deviation exists
Advisory Rules - guidance for best practices
Undefined Behavior - code constructs that are unpredictable across compilers
Deviation - formal documentation when a rule is intentionally not followed
Project Structure
Source code files (.c/.h) conforming to MISRA C
Configuration files for compliance checker
Documentation for deviations and exceptions
Build scripts ensuring rule compliance before compilation
Test suites for functional and safety verification
Building Workflow
Write C code following MISRA subset rules
Run static analysis to detect rule violations
Document justified deviations if any
Iterate and correct violations before integration
Review and verify compliance during code reviews
Difficulty Use Cases
Beginner: simple embedded C modules with basic rule compliance
Intermediate: multi-module avionics subsystems with full compliance checks
Advanced: integrating MISRA compliance in complex RTOS or safety-critical systems
Expert: full DO-178C software lifecycle including verification and deviation management
Certifier: auditing software projects for MISRA C adherence and safety compliance
Comparisons
MISRA C vs Standard C: safer, restricted subset
MISRA C vs CERT C: avionics vs general embedded safety
MISRA C vs DO-178C guidelines: MISRA is code-level, DO-178C is lifecycle-level
MISRA C vs Coding without guidelines: predictable, verifiable, and certifiable
MISRA C vs AUTOSAR C: automotive vs avionics standards
Versioning Timeline
1998 - MISRA C first edition for automotive
2004 - MISRA C:2004 introduced updates for embedded systems
2012 - MISRA C:2012 consolidated and enhanced rules
2016 - MISRA C:2012 Amendment 1, updated for wider safety-critical use
2020 - MISRA C:2020 revised for modern C and embedded applications
2023 - Latest updates focus on avionics-specific guidance and tool support
Glossary
Undefined Behavior - operations with unpredictable outcome
Deviation - formally documented exception to a rule
Rule Classification - mandatory, required, advisory
Static Analysis - automated code inspection for compliance
Embedded System - dedicated hardware with software for a specific function