That’s all documented in the standard though. Why would you access errno any other way?
errno = 0
// code which may error here
if(errno) { … }
And that errno is notably not scoped, so the code which may error should only be composed of calls to libc, or code whose interaction with libc you understand perfectly, otherwise you need to save and restore errno around uncontrolled calls.This is quite verbose, annoying, and error prone.
> errno = 0 > // code which may error here > if(errno) { … }
Which are the functions that set errno, and only errno, on failure?
In practice, you will clear errno once, and then repeatedly check for failure after every call to a libc function.
> And that errno is notably not scoped, so the code which may error should only be composed of calls to libc, or code whose interaction with libc you understand perfectly, otherwise you need to save and restore errno around uncontrolled calls.
I don't understand what this means.
It's a pain, and if it's not done correctly by everyone then it leaves you with subtle intermittent bugs.