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


Naming Variables and Functions

The names of global variables and functions in a program serve as comments of a sort. So don't choose terse names--instead, look for names that give useful information about the meaning of the variable or function. In a GNU program, names should be English, like other comments.

Local variable names can be shorter, because they are used only within one context, where (presumably) comments explain their purpose.

Please use underscores to separate words in a name, so that the Emacs word commands can be useful within them. Stick to lower case; reserve upper case for macros and enum constants, and for name-prefixes that follow a uniform convention.

For example, you should use names like ignore_space_change_flag; don't use names like iCantReadThis.

Variables that indicate whether command-line options have been specified should be named after the meaning of the option, not after the option-letter. A comment should state both the exact meaning of the option and its letter. For example,

/* Ignore changes in horizontal whitespace (-b).  */
int ignore_space_change_flag;

When you want to define names with constant integer values, use enum rather than `#define'. GDB knows about enumeration constants.

Use file names of 14 characters or less, to avoid creating gratuitous problems on older System V systems. You can use the program doschk to test for this. doschk also tests for potential name conflicts if the files were loaded onto an MS-DOS file system--something you may or may not care about.


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