What Is Barr-C?
Barr-C, the Barr Group’s coding standard, aims to reduce bugs in embedded software, as well as introduce stylistic guidelines to improve maintainability and portability.
Here, we explain what is Barr-C, how developers can detect bugs in firmware written in C with BARR-C:1018, and how it can be coupled with guidelines from MISRA.
Read along or jump ahead to the section that interests you most:
Enforce Barr-C Now with a Helix QAC Free Trial
Back to topWhat Is Barr-C?
Barr-C is an embedded C coding standard developed by the Barr Group that focuses on reducing the number of bugs in firmware while improving the maintainability and portability of embedded software.
BARR-C:2018 guidelines are divided into two main categories:
- Those dealing with subsetting the language such as avoiding specific keywords (e.g., “register” or “continue”) and the use of function-like macros.
- Those concerning programming style (for example, indentation and naming conventions).
Some of the rules in the first category are marked as “Zero Bugs…Period.” Following these rules will help prevent bugs in the first place.
Back to topWhy Is Barr-C Important?
Developing embedded software can be challenging, even with the right tools to identify defects and compliance issues.
BARR-C:2018 defines a style aimed primarily at minimizing coding errors. As a result, BARR-C:2018 can be seen as a first step to C language subsetting that is suitable for all kinds of projects.
The adoption of BARR-C:2018 is a major improvement with respect to the situation where no coding standards and no static analysis are used.
Back to topHow to Achieve Barr-C Compliance?
To be compliant with BARR-C:2018, it is mandatory to enforce all the guidelines.
There are several ways to detect non-compliant code; for example, informal code reviews or automated scans. The suggested method of enforcement is described in each rule. Many of the rules in the standard can be checked automatically using a static analysis tool – such as Helix QAC.
Back to topHow Does Barr-C Relate to MISRA?
Developers who are designing safety-critical systems know to follow MISRA C:2012 guidelines closely. Compliance to MISRA C:2012 ensures that embedded code is safe and secure.
BARR-C:2018 was not designed to compete against MISRA C:2012; they are in fact compatible and complementary. For example, a project using MISRA C:2012 can use the programming style portion of BARR-C:2018 to satisfy the MISRA C recommendation of adopting and enforcing a consistent coding style.
Similarly, critical projects can initially work towards compliance with Barr-C, then smoothly transition to MISRA C compliance.
📘 Related Resource: A Guide to MISRA C and C++
Back to topWhy Use Helix QAC for Barr-C Compliance
Helix QAC makes it easy to comply with coding standards and guidelines, including MISRA and Barr-C.
See for yourself how Helix QAC helps you comply with Barr-C and other functional safety standards.
Back to top