Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!chinet!rlk From: rlk@chinet.UUCP Newsgroups: comp.lang.c Subject: Re: A better perror() (Was: Re: Accessing argc ...) Message-ID: <1427@chinet.UUCP> Date: Thu, 20-Aug-87 23:19:12 EDT Article-I.D.: chinet.1427 Posted: Thu Aug 20 23:19:12 1987 Date-Received: Sat, 22-Aug-87 18:09:47 EDT References: <22@flmis06.ATT.COM> <28700015@ccvaxa> <853@mcgill-vision.UUCP> <1351@killer.UUCP> Reply-To: rlk@chinet.UUCP (Richard Klappal) Organization: Chinet - Public Access Unix Lines: 39 In article <1351@killer.UUCP> molly@killer.UUCP (Molly Fredericks) writes: >In article <853@mcgill-vision.UUCP>, mouse@mcgill-vision.UUCP (der Mouse) writes: >> In article <28700015@ccvaxa>, aglew@ccvaxa.UUCP quotes: >> > I have always thought that perror(str) was silly - sometimes I want >> > str to be the command name, sometimes the command plus all >> > arguments... >> >> [ ... ] Wish perror() were printflike, perhaps like >> syslog() - syslog() accepts a printf format, except that %m means >> insert sys_errlst[errno]. > >I have seen a few public domain printf's come down the line (the most ... My solution to this is extern int errno; extern char *sys_errlist[]; #define SYS_ERRMSG sys_errlist[errno] . . printf("..whatever..: %s\n", args_for_whatever, SYS_ERRMSG); This method assumes that 'errno' has been correctly supplied a value. (e.i., That an error occured.) Do an 'nm' command on libc.a to confirm the existence of these names, if not using a standard UN*X (works on SYSV, and on my BSD-derived system.) -- --- UUCP: ..!ihnp4!chinet!uklpl!rlk || MCIMail: rklappal || Compuserve: 74106,1021 ..!ihnp4!ihu1h!rlk ---