itemis Blog

Sketch of an Open Source implementation of AUTOSAR C++14 coding guidelines for critical systems

Written by Andreas Graf | Jan 31, 2018

C and C++ are widely used languages in the development of embedded systems. But both languages have their pitfalls which need to be avoided when the systems are safety-critical. One strategy is the usage of coding guidelines that define how the language should be used and which constructs should be avoided. 

Some of the most well-known standards are the MISRA family, which are widely supported by commercial tools. The new AUTOSAR specification "Guidelines for the use of the C++14 language in critical and safety-related systems" is an important contribution to the field.

Seven years ago, we already blogged about using the Eclipse C-Development environment (CDT) for interactive MISRA checks that are displayed directly while the developer edits the code. At that time, we did not pursue the activity much further, since MISRA-C licensing was quite incompatible with an open source implementation.

The AUTOSAR guidelines with their licensing offer new opportunities.


Technology behind Eclipse CDT

The Eclipse CDT project contains a subproject called CODAN, which provides a framework for extending code checks in the C/C++ IDE. The check-developer registers an Eclipse extension and implements a class, which will get called during validation. The class is being passed the information about the source code as an abstract syntax tree (AST), so no parsing is required.

The AUTOSAR C++ specification contains the following code guideline:

Rule M6-3-1 (required, implementation, automated)
The statement forming the body of a switch, while, do ...  while or for statement shall be a compound statement.

This can easily be implemented through Codan:

Community Source

While the MISRA licenses seemed very limiting for open source / community source activities, the AUTOSAR license provides more options. The Artop community already provides a framework for the implementation of AUTOSAR tools, which is freely available to all AUTOSAR members and would be a candidate for hosting such an activity. It would really be interesting to see if there is enough interest in the industry to collectively drive such a project.