Re: Handling 'initializer element not constant' error
Richard Tobin wrote, On 07/05/08 23:29:
One real example of this is current versions of glibc where after a bit
of digging I get
# define errno (* __errno_locatio n ())
--
Flash Gordon
Richard Tobin wrote, On 07/05/08 23:29:
In article <290288be-6c58-49e1-9bef-ec4e3e5de7ca@l4 2g2000hsc.googl egroups.com>,
<vippstar@gmail .comwrote:
>
>
The C standard recognises the problems with errno and doesn't require
it to be an identifier. It just has to be a macro that produces a
modifiable lvalue. So a threaded implementation can do something
like
>
#define errno (*__thread_errn o())
>
where __thread_errno( ) returns a pointer to a per-thread variable.
<vippstar@gmail .comwrote:
>
>I have not read much on alternative solutions to errno in C, so is
>there a better solution?
>Returning the error code is not possible (like pthreads) and an extra
>parameter to every function that can fail would be quite annoying.
>there a better solution?
>Returning the error code is not possible (like pthreads) and an extra
>parameter to every function that can fail would be quite annoying.
The C standard recognises the problems with errno and doesn't require
it to be an identifier. It just has to be a macro that produces a
modifiable lvalue. So a threaded implementation can do something
like
>
#define errno (*__thread_errn o())
>
where __thread_errno( ) returns a pointer to a per-thread variable.
of digging I get
# define errno (* __errno_locatio n ())
--
Flash Gordon
Comment