MISRA.UNDEF.WRONGNAMEUndefinition of a name from the standard library.
MISRA C 2012 Rule 21.1: #define and #undef shall not be used on a reserved identifier or reserved macro nameC90 [Undefined 54, 57, 58, 62, 71] C99 [Undefined 93, 100, 101, 104, 108, 116, 118, 130] Category: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 AmplificationThis rule applies to the following:
This rule does not include those identifiers or macro names that are described in the section of the applicable C standard entitled “Future Library Directions”.The Standard states that defining a macro with the same name as:
RationaleReserved identifiers and reserved macro names are intended for use by the implementation. Removing or changing the meaning of a reserved macro may result in undefined behaviour. Example#undef __LINE__ /* Non-compliant - begins with _ */ #define _ GUARD_H 1 /* Non-compliant - begins with _ */ #undef _BUILTIN_sqrt /* Non-compliant - the implementation * may use _BUILTIN_sqrt for other * purposes, e.g. generating a sqrt * instruction */ #define defined /* Non-compliant - reserved identifier */ #define errno my_errno /* Non-compliant - library identifier */ #define isneg( x ) ( ( x ) < 0 ) /* Compliant - rule doesn't include * future library * directions */ See alsoRule 20.4 Undefinition of a name from the standard library. MISRA-C 2004 Rule 20.2 (required): The names of standard library macros, objects and functions shall not be reused.This rule is also covered by MISRA.STDLIB.WRONGNAME, MISRA.STDLIB.WRONGNAME.UNDERSCORE AND MISRA.UNDEF.WRONGNAME.UNDERSCORE. Where new versions of standard library macros, objects or functions are used by the programmer (e.g. enhanced functionality or checks of input values) the modified macro, object or function shall have a new name. This is to avoid any confusion as to whether a standard macro, object or function is being used or whether a modified version of that function is being used. So, for example, if a new version of the sqrt function is written to check that the input is not negative, the new function shall not be named "sqrt" but shall be given a new name. MISRA-C++ 2008 Rule 17-0-2 (required): The names of standard library macros and objects shall not be reused.This rule is also covered by MISRA.UNDEF.WRONGNAME.UNDERSCORE. RationaleWhere the developer uses new versions of standard library macros or objects (e.g. to enhance functionality or add checks of input values), the modified macro or object shall have a new name. This is to avoid any confusion as to whether a standard macro or object, or a modified version of them, is being used. Example#define NULL ( a > b ) // Non-compliant |