home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sun / misc / 6137 < prev    next >
Encoding:
Text File  |  1993-01-05  |  3.0 KB  |  61 lines

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