Services and Modeling for Embedded Software Development
Embecosm divider strip
Prev  Next

5.3.1.  Error Handling

Many functions set an error code on failure in the global variable, errno.

There is a slight complication with newlib, because errno is not implemented as a variable, but a macro (this make life easier for reentrant functions).

The solution for standard system call implementations, which must return an error code is to undefine the macro and use the external variable instead. At the head of such functions use the following.

#include <errno.h>
#undef errno
extern int errno;
	  
[Note]Note

errno is a global variable, so changing it will immediately make a function non-reentrant.

Embecosm divider strip