What is errno in C?

You may see references to errno in C code. This is defined in <errno.h> as:

#define errno (*__error())

That is, errno dereferences a call to a function __error. This is defined as

extern int * __error(void);

That is, a function which takes no arguments and returns a non-null pointer to the error number.

The docs say

errno is defined by the ISO C standard to be a modifiable lvalue of type int

That is, we should be able to assign to errno. This is possible, because *V is also an lvalue.

These details aside, errno is basically a global int value. Its value is set by some system calls. It’s an assistant to the “return -1” idiom.

I just released Vidrio, a free app for macOS and Windows to make your screen-sharing awesomely holographic. Vidrio shows your webcam video on your screen, just like a mirror. Then you just share or record your screen with Zoom, QuickTime, or any other app. Vidrio makes your presentations effortlessly engaging, showing your gestures, gazes, and expressions. #1 on Product Hunt. Available for macOS and Windows.

With Vidrio

With generic competitor

More by Jim

Tagged . All content copyright James Fisher 2016. This post is not associated with my employer. Found an error? Edit this page.