What is errno really defined as

frank ernest doark@mail.com
Sun Nov 2 21:11:00 GMT 2014


>> Errno is declared as a function returning pointer to int and it does not
>> modify or read any golbal variables.
> 
> The way errno is defined actually makes it quite easy to read and write it
> from the application.
> 
> If you wrote:
> 
> errno = 0;
> 
> It would translate to:
> 
> (* __errno_location ()) = 0;
> 
> i.e. get the address of errno, then write 0 at that address.

[Then the light bulb appeared] Ah! I've nerver seen, or read anybody doing anything like that before in my life, and I've read at least 7 books on C.
This is really cool, but tells me nothing about the volitle or non-volitle state of errno. As for thread local storage, I'll have to read up on that.

Thanks, that is very interesting and worth while thing to know.



More information about the Libc-help mailing list