What is the domain of strerror()?

Steve Summit scs at adam.pika.mit.edu
Sun Apr 9 13:16:06 AEST 1989


In article <9997 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>That's easy; anything the standard says is an error number is allowed,
>and anything else is up to the implementation.  I.e. the non-zero value
>of errno, as set by some functions according to the standard, is an
>acceptable "error number" for strerror().

So if a weird number is somehow passed to strerror, the result is
undefined?  This seems like asking for trouble, particularly when
it's easy enough to use sprintf(tmpbuf, "Error %d", errno); as
many implementations do.  Having the result be implementation-
defined wouldn't be too bad if it meant that the text might be
different ("Error" vs. "error," perhaps) but I'd rather it not do
the equivalent of sys_errlist[-123] and dump core.

                                            Steve Summit
                                            scs at adam.pika.mit.edu



More information about the Comp.std.c mailing list