What is MISRA C

Micael Coutinho,programmingtoolingmisra

Learn here how following MISRA guidelines can help you build portable, reliable and easier to maintain C code

MISRA is a word often thrown around in the automotive industry, especially in when projects start coming close to completion. This is the first mistake, and by the end of this article, we hope you will understand why. First, let's us understand what MISRA means and how it has evolved throughout the years.

MISRA is a consortium that provides guidelines to develop software related to safety and security-minded systems. Being compliant to MISRA means your code is more trustworthy, as the end product will be robust, more portable and easier to maintain. Sounds pretty good, right? The MISRA acronym comes from "Motor Industry Software Reliability Association", and although it sounds much like automotive, MISRA is nowadays transversal to many sectors, which caught on with its potential. In essence, MISRA defines a set of guidelines, which are subdivided into rules and directives, where:

The first edition of MISRA C guidelines were introduced in 1998, but since then there have been a few updates. One of the most recent is the second amendment to MISRA C:2012, which was published in february 2020, containing 175 guidelines, from which there are 16 mandatory rules, 120 required rules and 39 are advisory. The differences between these 3 concepts are:

The MISRA C rules are be defined by the following categories:

Now, we can already see why static code analysis is a big thing. In the further parts of this article, we will explore each subset of these rules, and by the end, our crash course in MISRA C will be complete and we will all be pros!

Author: Micael Coutinho (opens in a new tab)

References:

© AutosarToday —@LinkedIn