This is the mail archive of the
mailing list for the glibc project.
Re: What is errno really defined as
- From: "frank ernest" <doark at mail dot com>
- To: libc-help at sourceware dot org
- Date: Sun, 2 Nov 2014 22:11:35 +0100
- Subject: Re: What is errno really defined as
- Authentication-results: sourceware.org; auth=none
- Sensitivity: Normal
>> 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.