Rule 1.1 of the MISRA C 2004 specifies that the spec covers c90 and not c99.
I would like to use the stdint and stdbool libraries instead of coding my own. Has anyone made this exception in their MISRA implementation?
Rule 1.1 of the MISRA C 2004 specifies that the spec covers c90 and not c99.
I would like to use the stdint and stdbool libraries instead of coding my own. Has anyone made this exception in their MISRA implementation?
You should definitely use the type names from stdint.h. This is how I have solved it, in a MISRA-C:2004 compliant way:
#ifdef __STDC_VERSION__
#if (__STDC_VERSION__ >= 199901L) /* C99 or later? */
#include <stdint.h>
#include <stdbool.h>
#else
#define C90_COMPILER
#endif /* #if (__STDC_VERSION__ >= 199901L) */
#else
#define C90_COMPILER
#endif /* __STDC_VERSION__ */
#ifdef C90_COMPILER
typedef unsigned char uint8_t;
typedef unsigned int uint16_t;
typedef unsigned long uint32_t;
typedef signed char int8_t;
typedef signed int int16_t;
typedef signed long int32_t;
#ifndef BOOL
#ifndef FALSE
#define FALSE 0u
#define false 0u
#define TRUE 1u
#define true 1u
#endif
typedef uint8_t BOOL;
typedef uint8_t bool;
#endif
#endif /* C90_COMPILER */