MISRA C/C++

What is MISRA?

MISRA consists of a group of likeminded individuals. As a collective, they provide guidelines for developing software associated with safety- and security-related electronic systems, and standalone software. Compliance with MISRA standards helps developers to produce code that is robust, maintainable, and more portable.

MISRA has been in existence for around 20 years, initially as a collaboration between the Ford and Rover motor companies who decided to combine their efforts to create a create a C language subset – or coding standard, as they are known colloquially. MISRA C has since gone on to become a reference standard for embedded C programming in many industries, whether safety is the primary consideration, or not. It is equally useful for code that has a requirement to be secure, for example.

Working group members are now drawn from industries and consultants across the safety-related embedded systems world, including the automotive sector.  LDRA have active representatives on several of those working groups, including the chairpersons of MISRA C and MISRA C++ working groups.

What does MISRA mean?

The name MISRA was originally an acronym of the Motor Industry Software Reliability Association. That expansion is no longer used because “MISRA” no longer implies “automotive”. MISRA standards are used in many other sectors too, and so the “Motor Industry” part of the acronym has become misleading over time.

Who uses MISRA standards?

MISRA’s name no longer includes reference to the motor industry, reflecting the fact that MISRA has gained acceptance in many other sectors including aerospace, medical devices, financial, IoT, and industrial control systems (IIoT).

For example, companies from the industrial & energy, medical device, and automotive sectors have all used LDRA tools to ensure that MISRA standards are complied with.

How do MISRA standards help?

Compliance with MISRA coding standards helps to:

  • improve portability through the avoidance of compiler- or platform-specific constructs
  • avoid unexpected application behaviour
  • identify unreachable or infeasible code which often suggests a defect and a potential security vulnerability
  • reduce unsafe and insecure coding practices by prohibiting certain language constructs
  • measurably reduce program complexity
  • improve program testability
  • ease compliance with functional safety and security standards
What rules are there in the MISRA standards?

The number of rules for each language varies in each edition. As an example, MISRA C:2012 (Third Edition, First Revision) includes 175 rules of which 16 are classified as Mandatory, 120 are Required, and 39 are Advisory.

Complete compliance matrices are available for MISRA C and MISRA C++. They detail all of the rules, and which ones are supported by LDRA tools.

What is next from MISRA?

Following an announcement in January 2019, work is ongoing to merge the MISRA and AUTOSAR C++ guidelines to develop a single “go to” language subset for safety-related C++ development. The resulting integrated MISRA–AUTOSAR C++ rule set published by MISRA will deliver a unified standard with a common set of rules. It will remain applicable to the automotive sectors and other sectors alike, and will be fully supported by LDRA.

What is a MISRA checker?

There are many rules in the MISRA standards. In theory it might be possible to check that they have all been implemented by inspection, but that would be a highly skilled, labour-intensive and error-prone job. MISRA checkers such as those provided by LDRA automate that process by means of static analysis.

How can LDRA help with MISRA compliance?

The ability to quickly and easily statically analyse software with reference to MISRA coding standards delivers tangible benefits to development teams in terms of code quality, consistency, and reduced time-to-deployment. LDRA is committed to supporting all versions of MISRA coding standards and can help in several ways.

What can LDRA static analysis find?

Static analysis can be initiated to ensure MISRA compliance as code is developed, and automatically applied during unit, system, or integration test to ensure that compliance achieved at the outset is not compromised throughout the software development life cycle. All versions of the MISRA rules are completely integrated into LDRA tools for efficient MISRA checking within a familiar development environment.

LDRA static analysis tools locate and highlight areas of non-conformant code to aid documentation and modification. Extensive reports and graphical displays enhance understanding of the source code, facilitating improvements in testability, understandability, and maintainability in line with MISRA rules. LDRA static analysis tools also facilitates structural coverage analysis to ensure that software “testedness” is measured and maintained, as recommended by the MISRA guidelines.

MISRA rules compliance tools from LDRA

  • The LDRA tool suite automates source code checking for conformance to any version of the MISRA language subsets.
  • The TBvision component of the LDRA tool suite automates source code checking. It includes checks for conformance to most of the rules specified by MISRA language subsets.
  • LDRArules is a cost-effective, stand-alone rules checker independent from the LDRA tool suite. It includes checks for conformance to most of the rules specified by MISRA language subsets.
  • The TBmisra module supplements TBvision or LDRArules to provide checking and reporting against a full set of MISRA rules as detailed in the LDRA compliance matrices.
  • The TBexclude supplementary module provides for the efficient management of justified rule violations.
LDRA MISRA C training courses

The pool of expertise that has developed LDRA’s tools for over 40 years and helps guide MISRA and other standards committees around the globe is now accessible to delegates from across the critical embedded application sectors.

LDRA has been a leader in software verification and requirements traceability tools for safety- and security-critical application development since 1975. LDRA’s experience and expertise helps guide standards committees across the world, and that same depth of knowledge provides outstanding learning opportunities for delegates across the critical embedded application sectors.

With training courses in MISRA C up to and including MISRA C:2012 (3rd Edition, 1st Revision), LDRA’s tutors can help forge a path to help delegates to develop safe, secure, compliant application code.