MISRA C2004的规则1.1规定该规范涵盖c90而不是c99。
我想使用stdint和stdbool库,而不是自己编写代码。有没有人在他们的MISRA实现中做了这个例外?
发布于 2013-01-16 20:45:51
您绝对应该使用stdint.h中的类型名称。这就是我如何解决它的,以MISRA-C:2004兼容的方式:
#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 */https://stackoverflow.com/questions/14340014
复制相似问题