Liste des Groupes | Revenir à cl c |
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>antispam@fricas.org (Waldek Hebisch) writes:>
>I believe that's not true, but certainly it is not /clearly/ true.>
A lot of time passed between 1978, when K&R was published, and
1989, when the first C standard was ratified. No doubt the C
standard unified different practices among many existing C
implementations, but it is highly likely that some of them
anticipated the rules that would be ratified in the C standard.
Looking at SVID 3rd edition (1989), size_t did not yet exist, so in
that particular case, there was no need to implicitly define it in
any header file.
>
For interfaces that require custom typedefs (for example, stat(2)),
the SVID requires the programmer include <sys/types.h> before
including <sys/stat.h>.
>
When size_t was added there were existing interfaces where the
argument was changed to require size_t/ssize_t. These interfaces
did not, at the time, require the programmer to include
<sys/types.h> or <stddef.h> in order to use the interface, for
example in the SVID memory(BA_LIB) interface description, the
programmer had been instructed that only <string.h> was required
for the str* functions, and <memory.h> was required for the mem*
functions - but the SVID noted at that time that the latter was
deprecated - the pending ANSI C standard was to require only
<string.h>.
>
So, when the arguments of memcpy/strcpy were changed from int to
size_t, they couldn't go back and require existing code to include
e.g. <stddef.h> to get size_t; POSIX chose to note in the
interface description that additional typedefs may be visible
when <string.h> is included.
>
"The <string.h> header shall define NULL and size_t as described
in <stddef.h>."
Les messages affichés proviennent d'usenet.