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