On Wed, 28 Jun 2006 21:41:44 -0700, John Stiles <email@hidden>
wrote:
Historically, it was a global.
In modern times, "errno" is a macro that calls a private function (I
think it's called __error() or something). This allows it to be
thread-safe. By and large, though, you can treat it as if it were a
global variable.
Watch out thou that if you need it's value multiple times you
should assign
it to a local variable because calling __error() clears its value:
int error = errno; // <== this expands to "(*__error())"
fprintf( stderr, "%s: error: %ld (0x%08lX) \"%s\".\n",
__PRETTY_FUNCTION__, error, error, strerror( error ));
If you used errno instead of error in the fprintf line then only
the first
call would return the error. The last two times it's called it
would return
zero (noErr).