Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!usc!apple!bionet!ig!ames!dftsrv!mimsy!oasys!stuart From: stuart@oasys.dt.navy.mil (Stuart Pearlman) Newsgroups: comp.lang.c Subject: Question about perror (was Re: FILE *fp[]; /* is this possible? */) Summary: Does the ansi C standard say anything about perror(). Keywords: perror(), ansi C, posix Message-ID: <4573@oasys.dt.navy.mil> Date: 29 Nov 90 21:59:23 GMT References: <1990Nov27.131327.21662@agate.berkeley.edu> <1990Nov28.152146.19560@ssd.kodak.com> <14603@smoke.brl.mil> Organization: David Taylor Research Center Lines: 21 In article <14603@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <1990Nov28.152146.19560@ssd.kodak.com> weimer@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@dt.navy.mil Trandes Corporation +1 301 459 0200 On-Contract-To: David Taylor Research Center +1 202 227 1428