Why have xxx_t typedef names

Doug Gwyn gwyn at smoke.brl.mil
Fri Feb 1 05:51:59 AEST 1991


In article <BEVAN.91Jan30084205 at rhino.cs.man.ac.uk> bevan at cs.man.ac.uk (Stephen J Bevan) writes:
>What is the purpose of the "_t" ... etc. postfixes ?
>It obviously makes any variables defined by a typedef'd type very
>clear, but is that important?  I think not.

Some people find it helpful, others don't.

The primary legitimate reason for this convention is to ensure that
type names do not collide with other uses of identifiers.  Unfortunately,
systems that have <sys/types.h> (e.g. POSIX ones) generally allow the
inclusion of <sys/types.h> to define a large number of nonstandard type
names, so that in a program including that header it is in fact UNWISE
for the application itself to define its own names of the form *_t.
This is yet another aspect of the "name space pollution" issue, brought
somewhat under control by X3J11 and to a lesser extent by P1003(.1), but
still a real problem for C applications.



More information about the Comp.lang.c mailing list