_t typedefs
Karl Heuer
karl at haddock.ima.isc.com
Mon Jan 22 07:08:33 AEST 1990
In article <11078 at attctc.Dallas.TX.US> bobc at attctc.Dallas.TX.US (Bob Calbridge) writes:
>Okay, I'll byte. What are "_t" typedefs? Especially the ubiquitous
>"size_t"? In what header file do you find it?
Most types (|FILE| is a historical exception) defined in the ANSI C standard
are in the |_t| namespace. |size_t| is an unsigned type representing object
sizes (e.g. the type returned by the |sizeof| operator). It is |unsigned int|
on most machines but would be |unsigned long| on a few (e.g. 16-bit PCs in
huge model). <sys/types.h> (which is not ANSI, but is found on Unix and POSIX
systems) also defines several names with the |_t| suffix.
Generally, a type is defined in each% header file that needs to mention it.
Since quite a few functions use |size_t|, it is defined in <stdio.h>,
<stdlib.h>, <string.h>, and <time.h> as well as its "natural header",
<stddef.h>.$
Karl W. Z. Heuer (karl at haddock.isc.com or ima!haddock!karl), The Walking Lint
________
% An exception is |va_list|, which is *not* defined in <stdio.h> even though
it is the type of the last arg to |vprintf|. The implementor must manually
expand the typedef in this case.
$ In order to get this right--without having one header blindly include
another, which is forbidden--the implementor has to put a guard around each
instance of the typedef, e.g.:
#if !defined(_T_SIZE)
#define _T_SIZE
typedef unsigned int size_t;
#endif
More information about the Comp.lang.c
mailing list