You are here

Rules

The following C coding rules relate to selection and configuration of the compiler:

Rule 1.1.a.) All programs shall be written to comply with the [C99] version of the ISO Standard for the C Programming Language. (Note: This deviates from [MISRA04] Rule 1.1. Compilers compatible with [C99] offer many valuable improvements, including support for the fixed-width integer types, C++ style comments, the ability to declare automatic variables where needed, and inline functions. In the absence of a [C99]-compliant compiler, a [C90]-compliant compiler shall be used.)

Rule 1.1.b.) Whenever a C++ compiler is used, appropriate compiler options shall be set to restrict the language to the selected version of ISO C. (Note: This appears to deviate from [MISRA04] Rule 1.1, but is consistent with Rules 2.1 and 3.4, as well as MISRA-forseen deviations from Rule 1.1.)

Rule 1.1.c.) The use of proprietary compiler language keyword extensions, #pragmas, and inline assembly shall be kept to the minimum necessary to get the job done and be localized to a small number of device driver modules that interface directly to hardware.

Reasoning

Even “standard” C varies by compiler, but we need as common of a platform as we can find to make possible the rules and enforcement mechanisms that follow. C++ is a different language and the use of C++ and C should not be mixed in the same module.

Exceptions

These rules may be ignored in the case that the compiler supports only an older version of the C standard.