3 ms·
Consider you are trying to do a foreign function call from an interpreted language. You make the call and then want to check errno to see what the error was, bu
by aardvark179 4y ago
Consider you are trying to do a foreign function call from an interpreted language. You make the call and then want to check errno to see what the error was, but you don't know what precise C calls the runtime may have made in the meantime, or whether it might have reset errno. The only reliable thing to do is to mark library functions explicitly as modifying errno, and storing that somewhere else so that you can reliably retrieve that value.
It's a pain, and if it's not done correctly by everyone then it leaves you with subtle intermittent bugs.