What you’ll learn:
- What is MISRA C/C++?
- Why MISRA C/C++ helps in the development of safe and secure software.
- Why MISRA C/C++ isn’t just for automotive software development.
MISRA C and MISRA C++ are software-development guidelines designed to facilitate the development of safe and secure applications. MISRA C was started in 1997 by the MISRA Consortium, targeting automotive applications.
This is the first in a three-part series of videos and articles examining MISRA C/C++. I talked with Andrew Banks, Technical Specialist at LDRA/TASKING, about MISRA C/C++ (watch the video above).
C and C++ are programming languages designed to provide developers with unfettered access to hardware. They also put the onus on the programmer to not make mistakes, since an application tends to have access to the underlying system. Both have features that can be accidentally misused, and some areas with the language implementation are open to interpretation.
>>Check out this TechXchange for similar articles and videos
MISRA C/C++ limit the functionality of the programming language to ensure consistent use and operation, as well as make sure the programmer avoids error-prone features. The guidelines are a collection of rules, most of which can be implemented using static analysis.
How Does MISRA C/C++ Work?
MISRA C/C++ is typically implemented as part of a static-analysis tool designed to catch programming errors at compile time rather than runtime. Programmers can usually select which rules are to be applied, and code that doesn’t meet the requirements is flagged as an error.
Most static-analysis tools run prior to compiling, although some are implemented as part of the compiler. Most C/C++ compilers have flags that can be set to check for issues identical to some MISRA rules, but not all.
Where is MISRA C/C++ Used?
Though MISRA C originally targeted automotive applications, it’s been adopted by many other industries, ranging from transportation to medical. MISRA C/C++ support is useful for any C/C++ developer, as it will help reduce the number of errors in the code.
The AnalysisTools website lists static-analysis tools for C/C++ as well as other programming languages. Most of those for MISRA C/C++ are commercial offerings. Many open-source tools are able to provide support for most MISRA C/C++ rules, but not all of them. They also provide additional analysis that can be useful.
Preventing bugs in software is usually the goal of any programmer. Code quality matters and MISRA C/C++ can help.