tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH 1/6] fix ambiguous errno treating after mktime()



My 2c: preserving errno is not a desirable goal. Portable code
can't rely on it being preserved, people need to learn that,
and it's awkward to implement in some situations even when it
is possible.

Robert -- I have a query about your postscript:

Robert Elz <kre%munnari.OZ.AU@localhost> wrote:

> ps: it is actually quite hard to preserve errno, as it isn't
> guaranteed to be an Lvalue, ...

Um, is that so?  Has there been a standard that doesn't
require errno to be an lvalue, or implementations where it
isn't or wasn't?

Looking at "The Single Unix Specification, Version 2":

http://www.opengroup.org/onlinepubs/7990989775/xsh/errno.html

...
 APPLICATION USAGE

    Previously both POSIX and X/Open documents were more
    restrictive than the ISO C standard in that they required
    errno to be defined as an external variable, whereas the
    ISO C standard required only that errno be defined as a
    modifiable lvalue with type int.

    A program that uses errno for error checking should set it
    to 0 before a function call, then inspect it before a
    subsequent function call.
...

I read that to mean (and have always believed) that whatever
funky type errno is implemented as, it is required to be an
lvalue.  Unfortunately I don't have a copy of the ISO C
standard to hand to check what it says for C99.

Giles


Home | Main Index | Thread Index | Old Index