I have two use case for this Misra warning as mentioned below. Does compiler reserve some or specific name for #if defines which can't be used?
Currently, I have disabled this warning by //lint !e9071
but do we really need to do anything for such warnings? Is there any impact or risk if we disabled such warnings?
Case 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:
#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:
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.
The practical risk you run is your C standard library implementation using that symbol or even the compiler itself, which clashes with yours.
Part of C11 §7.1.3 Reserved identifiers says:
See also What does double underscore (__const
) mean in C?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With