home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / sun / admin / 8401 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.9 KB  |  51 lines

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