When developing new code, declare functions that return errno
with a return type of errno_t
. Many existing functions that return errno
are declared as returning a value of type int
. It is semantically unclear by inspecting the function declaration or prototype if these functions return an error status or a value or, worse, some combination of the two. (See ERR02-C. Avoid in-band error indicators.)
...
This recommendation depends on C11 Annex K being implemented and advocates using errno_t
in new code where appropriate. The following code can be added to remove this dependency:
...
Code Block | ||
---|---|---|
| ||
#ifndef __STDC_LIB_EXT1__ typedef int errno_t; #endif |
...