Question about perror (was Re: FILE *fp[]; /* is this possible? */)

Stuart Pearlman stuart at oasys.dt.navy.mil
Fri Nov 30 08:59:23 AEST 1990


In article <14603 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <1990Nov28.152146.19560 at ssd.kodak.com> weimer at ssd.kodak.com (Gary Weimer) writes:
>>    if ((fp[i]=fopen(file_name[i],"r+")) <= 0)
>>        perror("Error opening file");
>
>Please don't do this; on UNIX, perror() will report the reason for the last
>SYSTEM CALL failure, not the reason for failure of a library routine such as
>fopen().

Is perror() specified in the ansi C standard?  I avoid using perror()
after library routines such as fopen() because they can fail for other
reasons besides the system calls they make failing.  Are any of the
library functions specified in the standard guaranteed to set errno?
(Is errno even guaranteed to exist?)  What about posix 1003.1?  Does
it specify what functions you can call perror() after?


-- 
Stuart Pearlman					stuart at dt.navy.mil
Trandes Corporation				+1 301 459 0200
On-Contract-To: David Taylor Research Center	+1 202 227 1428



More information about the Comp.lang.c mailing list