[英]defined macro '__CCP_H__' is reserved to the compiler [MISRA 2012 Rule 21.1, required]
I have two use case for this Misra warning as mentioned below. 我对此Misra警告有两个用例,如下所述。 Does compiler reserve some or specific name for #if defines which can't be used? 编译器是否为#if定义保留了某些名称或特定名称而不能使用?
Currently, I have disabled this warning by //lint !e9071
but do we really need to do anything for such warnings? 目前,我已经通过//lint !e9071
禁用了此警告,但是我们真的需要对此类警告采取任何措施吗? Is there any impact or risk if we disabled such warnings? 如果我们禁用此类警告,将会有任何影响或风险吗?
Case 1: 情况1:
#ifndef __CCPPAR_H__
#define __CCPPAR_H__ //lint !e9071
#include "Ccp_Cfg.h"
#endif /* multiple inclusion protection - __CCPPAR_H__ */
Observed warning: 观察到的警告:
defined macro '__CCPPAR_H__' is reserved to the compiler [MISRA 2012 Rule 21.1, required]
Case 2: 情况2:
#ifndef __CCP_H__
#define __CCP_H__ //lint !e9071
#include "Ccppar.h"
#define MAJOR 0x02
#define MINOR 0x01
/* other parts of code */
#endif
Observed below Misra warnings: 观察到以下Misra警告:
defined macro '__CCP_H__' is reserved to the compiler [MISRA 2012 Rule 21.1, required]
The C standard, let alone MISRA, reserves all tokens starting with a double underscore. C标准(更不用说MISRA)保留以双下划线开头的所有令牌。
The practical risk you run is your C standard library implementation using that symbol or even the compiler itself, which clashes with yours. 运行的实际风险是使用该符号甚至编译器本身的C标准库实现,与您的代码冲突。
Part of C11 §7.1.3 Reserved identifiers says: C11§7.1.3的保留标识符的一部分说:
See also What does double underscore ( __const
) mean in C? 另请参见C中的双下划线( __const
)是什么意思?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.