Re: function question
- From: Casper H.S. Dik <Casper.Dik@xxxxxxxxxxxxx>
- Date: 03 May 2012 21:01:42 GMT
"Bill Cunningham" <nospam@xxxxxxxxxxxxx> writes:
Volker Birk wrote:
Bill Cunningham <nospam@xxxxxxxxxxxxx> wrote:
errno = 0;
You shouldn't set errno yourself. The behaviour is undefined.
There is one function that returns -1 on success. I can't remember if
it's a standard C function or a system call. With it I have read that it is
sugessted to set errno to zero. errno never sets itself to zero and I
believe all system calls return -1 on error.
Needed for functions such as strtol, strtoll, atol, atoll, atoi where
the (Solaris) manual page says:
Because 0, LONG_MIN, LONG_MAX, LLONG_MIN, and LLONG_MAX are
returned on error and are also valid returns on success, an
application wishing to check for error situations should set
errno to 0, call the function, then check errno and if it is
non-zero, assume an error has occurred.