MISRA C
More info
- Creator
- MISRA (Motor Industry Software Reliability Association)
- Released
- 1998
- Type
- Coding standard
- Website
- misra.org.uk
A set of rules that carves the most dangerous parts out of C, originally for car engine control units.
C hands the programmer plenty of rope, undefined behaviour being one of the longer lengths. The British consortium MISRA published guidelines for using the language in vehicles in 1998, revised since in 2004, 2012 and 2023. Rules are graded mandatory, required or advisory: no dynamic memory allocation after start-up, no recursion, explicit type conversions, no implicit fall-through in switch.
Nobody holds every rule in their head, so compliance is checked by static analysers that complain loudly. Deviations are allowed but must be documented. MISRA C is now used far beyond cars — medical devices, aerospace, rail — because an assessor would much rather read "we follow MISRA with these deviations" than a home-grown style guide.