Achieve Uncompromising Safety and Reliability with MISRA®
MISRA® provides best-practice coding guidelines for C and C++. Especially in sectors where trust and safety are paramount — like automotive, medical technology, and aerospace and defense — the integrity of the embedded software can have a life-saving impact. Many such industries are required (or strongly recommended) to adhere to the MISRA guidelines for this reason.
Adopting the MISRA standard is far more than a regulatory requirement; it is a proactive strategy for reducing risk, avoiding costly failures, and supporting long-term maintainability across safety-critical applications. Organizations that implement MISRA guidelines — and use tools that speed up the process, like static analysis — deliver innovative software that also meets stringent safety and compliance requirements.
Consider this your guide to MISRA C and MISRA C++.
Read along or jump to the section that interests you most:
- What Is MISRA®?
- Why Use MISRA Standards?
- Important MISRA C Rules With Examples
- Important MISRA C++ Rules With Examples
- How to Achieve MISRA Compliance
Accelerate MISRA Compliance with Perforce QAC
What Is MISRA®?
MISRA provides coding standards for developing safety-critical systems.
MISRA is made up of vehicle manufacturers, component suppliers, and engineering consultancies. Perforce are members of the MISRA Consortium Limited and our experts are members of the MISRA Working Groups.
First developed in 1998, MISRA guidelines address the unique challenges posed by C and C++ programming languages in embedded safety-critical applications. By imposing precise rules and eliminating ambiguous constructs, MISRA guidelines help developers produce code that is safe, consistent, and robust.
📕 Related White Paper: How to Write Secure Code in C
Why Use MISRA Standards?
You can use MISRA standards to ensure your code is:
- Safe
- Secure
- Reliable
- Portable
📕 Related White Paper: What Is MISRA? An Overview of the MISRA Standard
The MISRA C coding standard was originally written for the automotive embedded software industry. But today, MISRA standards for C and C++ are widely used by embedded industries — including aerospace and defense, telecommunications, medical devices, and rail.
Most of these industries have a compliance requirement to use a coding standard — such as ISO 26262 for automotive functional safety.
📕 Related White Paper: How to Comply With the ISO 26262 Standard
See Perforce QAC MISRA Compliance Modules in Action!
What Are MISRA C Rules and Guidelines?
MISRA C is the most widely used set of coding guidelines for C around the world. Here is a quick look at how the MISRA guidelines have evolved since the 1998 publication.
MISRA C:2004 (MISRA C2)
MISRA C:2004 is the second edition of MISRA C, published in 2004. It was written for C90. There are 142 coding rules. The update was made to address:
- Language consistency
- Specific rules targeting Undefined Behavior only
- "One rule, one issue" to break down complex rules for ease of compliance
- Expanding and improving code examples
- Removing the option for tool-less use.
MISRA C:2012 (MISRA C3)
MISRA C:2012 is the third edition of MISRA C, published in 2013. It was written for C99 and C90 to provide better rationales for the guidelines and more precise descriptions. There are 143 rules and 16 directives.
📕 Related White Paper: 6 Key Changes in MISRA:C 2012
In subsequent years, MISRA published four amendments, which were in 2023 rolled up into the MISRA C:2023 version of the standard.
MISRA C:2012 Amendment 1
MISRA C 2012 Amendment 1 was released in 2016. The aim of AMD1 was to add new security guidelines. With this amendment, MISRA C:2012 includes 156 rules and 17 directives for a total of 173 guidelines.
MISRA C:2012 Amendment 2
MISRA C 2012 Amendment 2 was released in 2020 and adds coverage for C11 core functionality. It adds two new rules. With this amendment, MISRA C:2012 includes 158 rules and 17 directives for a total of 175 guidelines.
MISRA C:2012 Amendment 3
MISRA C 2012 Amendment 3 was released in 2022 and adds guidance for C11 and C18 new features previously prevented by Rule 1.4. It adds 24 new rules and 1 new directive. This makes a total of 182 rules and 18 directives, for a total of 200 guidelines.
Additionally, a number of existing guidelines have been revised together with supporting materials.
The new rules include further guidance on some of the emergent features previously covered by Rule 1.4, specifically:
Rules 8.15-8.17
Alignment of objects (<stdalign.h>)
Rules 17.9-17.13
No-return functions (<stdnoreturn.h>)
Rules 23.1-23.7
Type generic expressions (_Generic)
Rule 1.4 has been updated to remove the guidance on these features provided in Amendment 2.
Further guidance is provided with:
Rule 1.5
Obsolescent language features shall not be used
Rule 6.3
Bit field in unions
Rule 7.5
Integer-constant macros
Rule 18.9
Object lifetime
Rules 21.22-21.23
Type generic math macros (<tgmath.h>)
Rule 21.24
The random number generator functions of <stdlib.h>
Directive 4.15
Floating point (including comparisons, NaNs, and infinities)
The essential type model has been extended to include of essentially complex floating.
MISRA C:2012 Amendment 4
Amendment 4 was released in 2023 and completes guidance for C11 and C18 new features to include multithreading (Rules 22.11 - 22.20) and atomics (updates to various rules). AMD4 adds 19 new rules and directives, with 221 guidelines total.
MISRA C:2023
A revision of MISRA C:2012 was published in 2023. It is a rollup of all the previous amendments and technical corrigenda and is known as MISRA C:2023. MISRA C:2023 covers C90, C99, and C11/C18. It adds 200 new rules and 21 directives, with 221 guidelines total. MISRA C:2023 is also referred to as MISRA C Third Edition, second revision.
MISRA C:2025
While not as substantive as MISRA C:2023, MISRA C:2025, published in March 2025, builds on the previous version incrementally and covers C90, C99, and C11/C18. It also rationalizes and reorganizes existing guidelines for continuity, and adds new guidelines for a total of 225 active guidelines.
📕 Read more about the changes in MISRA C:2025
What Are MISRA C++ Rules and Guidelines?
After C was addressed by MISRA and considered more suitable for safety-critical systems, MISRA turned its attention to C++, which was being increasingly used at the time without a set of guidelines. The first MISRA C++ guidelines were published in 2008.
Today, MISRA C++ is widely used by safety-critical developers.
MISRA C++2008
MISRA C++:2008 was published in 2008. It was written for C++03. There are 228 coding rules, including:
Rule 5-0-13
The condition of an if-statement and the condition of an iteration statement shall have type bool.
MISRA C++:2023
MISRA C++:2023 is a new standard for use with modern C++ up to C++17 and incorporating AUTOSAR guidelines.
📕 Related Resource: MISRA and AUTOSAR to Unite C++ Coding Guidelines — What This Means
The latest version of MISRA C++ includes a new rule centering on for-loops in C++ to help avoid the undefined behavior that can occur when the for-range initializer of a range-based for-statement creates a temporary object.
Get a breakdown of exactly why this occurs and how the new rule guards against undefined behavior in our blog, Avoiding Bugs in Range-Based For-Loops with MISRA C++:2023.
How to Achieve MISRA C and MISRA C++ Compliance?
Achieving MISRA compliance takes knowledge, skill, and the right tools.
Here are seven steps to comply with MISRA:
1. Know the Rules
You need to know the MISRA coding rules pertinent to which version of C or C++ you’re using.2. Check Your Code Constantly
Continuously inspecting your code for violations is the best way to improve quality.3. Set Baselines
Embedded systems come with legacy codebases. By setting baselines, you can focus on making sure your new code is compliant.4. Prioritize Violations Based on Risk
You could have hundreds or even thousands of violations in your code. That’s why it’s important to prioritize rule violations based on risk severity. Some static code analysis tools can do this for you.5. Document Your Deviations
Sometimes there are exceptions to the rule. But when it comes to compliance, every rule deviation needs to be well-documented.6. Monitor Your MISRA Compliance
Keep an eye on how MISRA compliant your code is. Using a static code analyzer makes this easier by automatically generating a compliance report.7. Choose the Right Static Code Analyzer
Choosing the right static code analyzer makes everything else easy. It takes care of scanning your code — new and legacy — for violations. It prioritizes vulnerabilities based on risk.
Complying with MISRA is important for many development teams today. Especially as virtualization rises.
📕 Related Resource: See how an automotive hypervisor achieves MISRA compliance 🚗
But not all MISRA checkers are the same…
📕 Related Resource: How to Compare MISRA Checkers
Using Perforce QAC For MISRA C Rules
Perforce QAC finds and reports on violations of MISRA rules and directives in C and C++.
Here's a short demo using Perforce QAC with MISRA C:2012 guidelines.
Why Use Perforce QAC for MISRA Compliance?
- Independently certified for use in the development of safety-critical software.
- Fully documented rule enforcement and message interpretation.
- Supplied with extensive example code.
- Fully configurable rules processing.
- Compliance reports for functional safety audits.
How Embedded Developers Use Perforce QAC For MISRA?
See how leaders in embedded industries — automotive, aerospace, and rail — use Perforce QAC and MISRA.
Image
| Image
| Image
|
Try Perforce QAC for MISRA C and C++
See why Perforce QAC is the best static code analyzer for MISRA C and C++.