Variable Name Conventions

Karl Heuer karl at haddock.ima.isc.com
Sat Jan 20 07:27:44 AEST 1990


In article <36190 at cornell.UUCP> gordon at cs.cornell.edu (Jeffrey  Adam Gordon) writes:
>I have seen C source with at least three different types of variable
>names.  Some are just 'var' while others are either '_var' or '__var.'
>What I'd like to know is:  is there any convention for using
>underline (and for that matter, CAPS) in C variable/function/structure
>names.  Does anyone have a neat system they like to use when, say,
>defining typedefs (such as "all typedefs will end in '_t') or
>pointers (like '_p').

If you're a user (rather than the implementor of the C runtime system) then
you should avoid creating any names beginning with underscore, as most of
these are reserved by ANSI C.

Likewise, you should probably not use _t for your own typedefs, because POSIX
reserves this entire class for use in <sys/types.h>.

Beyond this, it's pretty much personal convention, which should probably be
discussed off-line to keep the S/N ratio from deteriorating too badly.

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



More information about the Comp.lang.c mailing list