[comp.lang.c] _t typedefs

bobc@attctc.Dallas.TX.US (Bob Calbridge) (01/21/90)

Okay, I'll byte.  What are "_t" typedefs?  Especially the ubiquitous
"size_t"?  In what header file do you find it?
 
Thanks,
Bob
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=    More stupid questions available on request from                          =
-     bobc@attctc                     Your humble servant (real humble)       -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

karl@haddock.ima.isc.com (Karl Heuer) (01/22/90)

In article <11078@attctc.Dallas.TX.US> bobc@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@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