home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!auspex-gw!guy
- From: guy@Auspex.COM (Guy Harris)
- Newsgroups: comp.sys.sun.admin
- Subject: Re: HELP: Need errno.h (strerror) from ACC
- Keywords: C++, ERRNO, ACC
- Message-ID: <15548@auspex-gw.auspex.com>
- Date: 18 Nov 92 19:31:20 GMT
- References: <glenn.70.722096254@admin.acadiau.ca>
- Sender: news@auspex-gw.auspex.com
- Organization: Auspex Systems, Santa Clara
- Lines: 37
- Nntp-Posting-Host: bootme.auspex.com
-
- > I am trying to compile a public domain program that was made using
- >SUN's ACC compiler. I only have GCC available to me on our SUN. I have
- >attempted compiling by making the appropriate changes to the Makefile but
- >there is one thing still missing. That one thing is the routine "strerror"
- >which is supposed to exist in errno.h but GCC does not have it. Would it be
- >possible (and legal I assume) for someone to e-mail me that routine from the
- >ACC errno.h file so that I can add it directly to this source code. Thanks.
-
- Err, I don't think ACC supports inlining; as such, "strerror()" is
- unlikely to be *defined* in "errno.h", or any other include file,
- although it is, according to the ANSI C spec, supposed to be *declared*
- by <string.h> or some file that <string.h> includes.
-
- It's defined by "libansi.a" in the Sun C release we have here.
-
- However, it's a fairly trivial routine to write for UNIX. Here's a
- freely-available and freely-redistributable version I wrote (hell, it's
- public-domain - too little code for me to give a damn about copyrighting
- it). No warranty; if you find a bug, it's your problem:
-
- char *
- strerror(int errnum)
- {
- extern int sys_nerr;
- extern char *sys_errlist[];
- static char errbuf[5+1+10+1]; /* "Error %d\0" */
-
- if (errnum > 0 && errnum < sys_nerr)
- return sys_errlist[errnum];
- else {
- (void) sprintf(errbuf, "Error %d", errnum);
- return errbuf;
- }
- }
-
- Dunno what state the GNU library is in, but it presumably also has a
- version of "strerror()" in it.
-