home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sun / misc / 6082 < prev    next >
Encoding:
Text File  |  1992-12-31  |  2.7 KB  |  54 lines

  1. Newsgroups: comp.sys.sun.misc
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxh.cso.uiuc.edu!swofford
  3. From: swofford@uxh.cso.uiuc.edu (David Swofford )
  4. Subject: Re: Sun's ANSI C
  5. References: <1992Dec30.164547.24172@stortek.com>
  6. Message-ID: <C04uHC.Bt2@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Organization: University of Illinois at Urbana
  9. Date: Thu, 31 Dec 1992 16:43:58 GMT
  10. Lines: 42
  11.  
  12. alec@stortek.com (Alec Sharp - x2955) writes:
  13.  
  14. >We've been using the standard Sun C compiler on SunOS 4.1.x, and have just bought
  15. >a copy of the ANSI compiler so that we can investigate moving to ANSI C. I tried
  16. >compiling and linting some programs and noticed a problem with the function 
  17. >prototypes, some of which don't seem to conform to ANSI (I've included some examples
  18. >below, with Sun's version first, then what I read as the ANSI standard). 
  19.  
  20. >Has anyone else noticed this? If so, what did you do?  If what I see is
  21. >really what Sun produces, I'm rather disappointed with their quality control.
  22.  
  23. [Examples deleted]
  24.  
  25. On page 76-77 of the "Sun ANSI Programmer's Guide" is the following:
  26.  
  27. "Some of the functions in SunOS 4.1. libc do not behave as specified by the
  28. ANSI standard.  These differences are detailed below..." (the ones included
  29. in your examples plus maybe a few others).
  30.  
  31. I was *FURIOUS* when I discovered this.  I bought the compiler because it
  32. was "Sun ANSI C".  In the preface of the manual it says "Sun ANSI C is Sun's
  33. ANSI-compliant compiler that runs on SunOS 4.1."  But in the "Read this first"
  34. section of the manual it says "Sun ANSI C is intended as a transition compiler
  35. from Sun C to a fully compliant ANSI C".  For most users, the differences
  36. probably won't matter (e.g., who cares whether malloc returns a char*
  37. or a void*, since it's almost always cast to something else anyway?).  But
  38. calling a compiler "ANSI-compliant" when some functions return totally
  39. different kinds of values is ABSURD.  The one that really got me was sprintf.
  40. In my application, I need to format a string via sprintf and know how long the
  41. resulting string is.  ANSI requires sprintf to return an integer representing
  42. the length of the formatted string, but in Sun's "ANSI" C, sprintf still 
  43. returns a char*.  So I still have to do strlen calls after sprintf's, when I
  44. should just be able to look at the sprintf return value, which uglies up the
  45. code with #if SUN ... #else .... #endif constructs.
  46.  
  47. Does anyone know if the unbundled compiler being sold with Solaris 2.x is
  48. fully ANSI-compliant? 
  49. -- 
  50. David L. Swofford                 Phone:    (217)244-6959
  51. Illinois Natural History Survey   FAX:      (217)333-4949
  52. 607 E. Peabody Drive              BITNET:   DAVESWOF@UIUCVMD
  53. Champaign, Illinois 61820 USA     Internet: swofford@uxh.cso.uiuc.edu
  54.