[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
On Mon, 01 Sep 2008, Robert Elz wrote:
> ps: it is actually quite hard to preserve errno, as it isn't
> guaranteed to be an Lvalue, it is quite possible on some systems
> there's no (reputable) way to assign a value to it,
I think you are confusing "errno isn't guaranteed to be an extern int"
with "errno isn't guaranteed to be an lvalue".
n1256.pdf (a 2007 draft of an update to the C99 standard) section 7.5
paragraph 2 says that errno is a modifiable lvalue, says that it's
unspecified whether it's a macro or an identifier with external linkage,
and refers to footnote 175, which reads in full "The macro errno need
not be the identifier of an object. It might expand to a modifiable
lvalue resulting from a function call (for example, *errno())." I find
the example confusing, because the "errno" in "*errno()" is not the
same "errno" that the rest of the paragraph is talking about; imagine
"#define errno *__errno()" instead.
Earlier standards (or common practice) specified "extern int errno;",
but that's no longer the case, and old code that declares "extern int
errno;" might not work. However, new or old code that assigns to errno
should work, provided it has "#include <errno.h>".
--apb (Alan Barrett)
Main Index |
Thread Index |