Go to the first, previous, next, last section, table of contents.


Naming Conventions

I use a modified Hungarian naming convention for my variables and functions. As with all naming conventions, the code is rather opaque if you are not familiar with it, but becomes clear and easy to use with time.

The first character indicates the type of the variable (or function return value). Sometimes additional characters are used. I use the following type prefixes:

`a'
array; the next character is the type of an element
`b'
byte or character
`c'
count of something
`e'
stdio FILE *
`f'
boolean
`i'
generic integer
`l'
double
`o'
file descriptor (as returned by open, creat, etc.)
`p'
generic pointer
`q'
pointer to structure
`s'
structure
`u'
void (function return values only)
`z'
character string

A generic pointer (p) is sometimes a void *, sometimes a function pointer in which case the prefix is pf, and sometimes a pointer to another type, in which case the next character is the type to which it points (pf is overloaded).

An array of strings (char *[]) would be named az (array of string). If this array were passed to a function, the function parameter would be named paz (pointer to array of string).

Note that the variable name prefixes do not necessarily indicate the type of the variable. For example, a variable prefixed with i may be int, long or short. Similarly, a variable prefixed with b may be a char or an int; for example, the return value of getchar would be caught in an int variable prefixed with b.

For a non-local variable (extern or file static), the first character after the type prefix is capitalized.

Most static variables and functions use another letter after the type prefix to indicate which module they come from. This is to help distinguish different names in the debugger. For example, all static functions in `protg.c', the `g' protocol source code, use a module prefix of `g'. This isn't too useful, as a number of modules use a module prefix of `s'.


Go to the first, previous, next, last section, table of contents.