Posts: 2
Threads: 2
Joined: May 2010
Reputation:
0
According to the rule 20.5, error indiaction facility should not be used even if it is well defined.
1)Is it mean that we should not declare the identifier(function and variable) with the name "errno"?
2)As per the standard library for linux "errno" MACRO is defined to function pointer call and for Visual C++ it is extern variable declaration. So does usage of "errno"(i.e. function call) on linux also violates the rule 20.5?
<t></t>
Posts: 70
Threads: 8
Joined: Dec 2007
Reputation:
0
According to the rule "errno" shouldnt be used at all, because it -isn't- well defined. It is only relevant how it is defined in ISO C, not in some homemade C standard for this or that OS.
<t></t>
Posts: 3
Threads: 1
Joined: Nov 2008
Reputation:
0
void foo()
{
int errno;
errno = GetValue();
if(errno == 0) //Is this usage of errno violates the rule 20.5, errno is user defined variable not from the errno.h
{
}
}
int GetValue()
{
return 10;
}
<r><COLOR color="#FF40FF"><s></s>Pundlik Oulkar<e></e></COLOR></r>
Posts: 70
Threads: 8
Joined: Dec 2007
Reputation:
0
Why would you use Linux & GCC on a safety-critical application anyhow... It will be an incredible painful and time-consuming process to ensure that the tool lives up to MISRA, let alone Linux itself. For example, MISRA mentiones that the maker of the tool should have a quality system, validation activities etc etc. How you can say that a semi-hobbyist open-source compiler lives up to that, I have no idea.
<t></t>
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
(1) "errno", like many other identifiers used in the standard headers, is reserved so you should NOT attempt to use it for your own purposes. You could use something like error_number instead.
(2) The standard permits errno to be implemented as a macro or as an identifier declared with external linkage. It is a violation of rule 20.5 to use errno, regardless of its implementation.
As pointed out by previous correspondents errno has a lot of implementation defined behaviour associated with it in ISO C.
Posted by and on behalf of the MISRA C Working Group