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