Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: clarified this recommendation is for new code and how to remove the dependency on Annex K

When developing new code, declare functions that return errno with a return type of errno_tMany 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
languagecpp
#ifndef __STDC_LIB_EXT1__
  typedef int errno_t;
#endif

 

...