MISRA Discussion Forums

Full Version: about rule20_5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
void func()
{
int errno;//does even declaration of errno violates rule20_5,errno is user defined?
}
Manisha Nikambe Wrote:void func()
{
int errno;//does even declaration of errno violates rule20_5,errno is user defined?
}

YES. It is that simple. You can not use "errno"

In any event rule 20.5 does not apply here. You are not useing errno. You are using your own version. The rule that does apply here is 20.1 "Reserved identifiers, macros and functions inthe standard library shall not be defined, redefined or undefined."

[ removed by moderator ]
The previous poster is not quite correct. Defining your own version of errno does not violate Rule 20.5. However, reusing any identifiers reserved for use by the standard library does violate Rule 20.2 (note, not Rule 20.1 as stated by the previous poster which prohibits redefinition using macros).