home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sun / misc / 6104 < prev    next >
Encoding:
Text File  |  1993-01-02  |  3.5 KB  |  80 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!cs.utexas.edu!sun-barr!west.West.Sun.COM!cronkite.Central.Sun.COM!sixgun.East.Sun.COM!seven-up.East.Sun.COM!sungy!stasys!alanya!lupe
  2. From: lupe@ukw.uucp (Lupe Christoph)
  3. Newsgroups: comp.sys.sun.misc
  4. Subject: Re: Sun's ANSI C
  5. Message-ID: <1993Jan2.191644.21061@ukw.uucp>
  6. Date: 2 Jan 93 19:16:44 GMT
  7. References: <1992Dec30.164547.24172@stortek.com> <C04uHC.Bt2@news.cso.uiuc.edu>
  8. Sender: news@stasys.sta.sub.org
  9. Organization: cic
  10. Lines: 68
  11.  
  12. swofford@uxh.cso.uiuc.edu (David Swofford ) writes:
  13.  
  14. >alec@stortek.com (Alec Sharp - x2955) writes:
  15.  
  16. >On page 76-77 of the "Sun ANSI Programmer's Guide" is the following:
  17.  
  18. >"Some of the functions in SunOS 4.1. libc do not behave as specified by the
  19. >ANSI standard.  These differences are detailed below..." (the ones included
  20. >in your examples plus maybe a few others).
  21.  
  22. >I was *FURIOUS* when I discovered this.  I bought the compiler because it
  23. >was "Sun ANSI C".  In the preface of the manual it says "Sun ANSI C is Sun's
  24. >ANSI-compliant compiler that runs on SunOS 4.1."  But in the "Read this first"
  25. >section of the manual it says "Sun ANSI C is intended as a transition compiler
  26. >from Sun C to a fully compliant ANSI C".  For most users, the differences
  27. >probably won't matter (e.g., who cares whether malloc returns a char*
  28. >or a void*, since it's almost always cast to something else anyway?).  But
  29. >calling a compiler "ANSI-compliant" when some functions return totally
  30. >different kinds of values is ABSURD.  The one that really got me was sprintf.
  31. >In my application, I need to format a string via sprintf and know how long the
  32. >resulting string is.  ANSI requires sprintf to return an integer representing
  33. >the length of the formatted string, but in Sun's "ANSI" C, sprintf still 
  34. >returns a char*.  So I still have to do strlen calls after sprintf's, when I
  35. >should just be able to look at the sprintf return value, which uglies up the
  36. >code with #if SUN ... #else .... #endif constructs.
  37.  
  38. Please note that Sun is talking about the *operating system* rather than
  39. the compiler. The SPARCcompiler uses the standard SunOS libraries. And
  40. *I* would be furious if it came with it's own, reducing interoperability.
  41.  
  42. My 2.0.1 release has an appendix C with a table of differences between
  43. the SunOS 4.1.x, SunOS 5.0, and ANSI C.
  44.  
  45. >Does anyone know if the unbundled compiler being sold with Solaris 2.x is
  46. >fully ANSI-compliant? 
  47.  
  48. The same table leave these differences:
  49.  
  50. ---libc---
  51.  
  52. Sun                ANSI
  53.  
  54. typedef int size_t        typedef unsigned int size_t
  55. char *memchr(char *,        void *memchr(const void *,
  56.     int, size_t);            int, size_t);
  57. int memcmp(char *,        int memcmp(const void *,
  58.     char *, int);            const void *, size_t);
  59. char *memset(char *,        void *memset(void *,
  60.     int, int);                int, size_t);
  61. char *memcpy(char *,        void *memcpy(void *,
  62.     char *, int);            const void *, size_t);
  63.  
  64. There is a library libansi.a that supplies a few missing library functions
  65. for SunOS 4.x. It also redefines some.
  66.  
  67. ---other---
  68.  
  69. C 2.0.1 does not support "#pragma weak".
  70.  
  71. "The type qualifier const is not placed in a read-only area of storage."
  72. (Probably means that a "const" can still be changed by casting.)
  73.  
  74. There is a large number of header files with non-ANSI-isms in 4.x.
  75. -- 
  76. | ...!unido!ukw!lupe  (German EUNet, "bang")     |  Disclaimer:            |
  77. | lupe@ukw.UUCP       (German EUNet, domain)     |  This is an unofficial  |
  78. | suninfo!alanya!lupe (Sun Germany)              |  opinion of Christoph & |
  79. | Res non sunt complicanda praeter necessitatem. |  Imschweiler Consulting |
  80.