style for typedef names (was: Is typedef char BUFFER[20] legal?)

Karl Heuer karl at ima.isc.com
Sat Feb 9 08:54:20 AEST 1991


In article <1701 at bbxsda.UUCP> scott at bbxsda.UUCP (Scott Amspoker) writes:
>In article <1212 at tredysvr.Tredydev.Unisys.COM> paul at tredysvr.Tredydev.Unisys.COM (Paul Siu) writes:
>>Can anyone also tell me what is the most common style convention for type
>>names, I usually put them all in capitals.
>
>You're not alone here.  We tend to use uppercase names for typedefs also.

But it's extremely common to use all-caps for constants (e.g. BUFSIZ, EOF,
NULL).  I disrecommend using this convention for type names.  (The type FILE
is a historical wart; if it were being added today, it would almost certainly
be spelled file_t instead.)

You could use the xxx_t convention, but since this entire namespace is
technically reserved by the POSIX <sys/types.h> header, you might be better
off using a slight variant, e.g. xxx_T (with the final T capitalized to avoid
the potential collision).  Other common styles are initial-cap (typedef struct
{int x,y;} Point), and all lowercase (typedef int bool, int32).

This being a rather volatile topic, I think I'll refrain from making any
positive recommendations at this time.

Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list