home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18946 < prev    next >
Encoding:
Internet Message Format  |  1992-12-29  |  1.8 KB

  1. Path: sparky!uunet!munnari.oz.au!metro!basser.cs.su.oz.au!tmx!asstdc!bart!fredmail
  2. From: imb@asstdc.oz.au (michael butler)
  3. Newsgroups: comp.lang.c
  4. Subject: definition of strncpy stupid?
  5. Message-ID: <725386978.AA08942@bart.asstdc.oz.au>
  6. Date: Sun, 27 Dec 1992 03:06:00 +1100
  7. Sender: fredmail@bart.asstdc.oz.au
  8. Lines: 36
  9.  
  10. ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
  11.  
  12.  > On the other hand, X3J11 made explicit a few restrictions that already
  13.  > applied if you wanted to write portable code, which have the consequence
  14.  > that a C compiler is fully entitled to "know" about sprintf (and all the
  15.  > other library functions).
  16.  
  17.  [ .. ]
  18.  
  19. I was under the impression that a compiler's job was, in essence, the
  20. translation of the source language into a machine-executable program which
  21. performed the same "semantic intent" (to use Whitesmith's phrase) of the source
  22. code. Naturally, this facility is only ever "guaranteed" (in so far as any
  23. compiler can be proven "correct") if the source code is also both syntactally
  24. (sp?) and semantically correct.
  25.  
  26. The issue of optimization is not usually a specified part of the process. It is
  27. only a promise by the compiler author(s) that, under certain conditions and
  28. probably with some restrictions, a particular compiler is capable of
  29. recognizing that it can translate a specific set of statements into "more
  30. efficient" executable code.
  31.  
  32. Largely, therefore, optimization is the application program author's
  33. responsibility since it is beyond the scope of the "portable" language
  34. definition (whether it be ANSI or not). If you want "strncpy" in lieu of
  35. "sprintf", why not say it ?
  36.  
  37. If a particular compiler "knows sprintf", then well and good, but an
  38. applications programmer has no right to expect that it might,
  39.  
  40.     michael
  41.  
  42. --
  43.  Assorted C Software - asstdc.oz.au - 3:712/400@fidonet
  44.       PO Box 595, Kensington NSW, Australia 2033
  45.  
  46.