19. Lint

Lint is a C program checker [2], [11] that examines C source files to detect and report type incompatibilities, inconsistencies between function definitions and calls, potential program bugs, etc. The use of lint on all programs is strongly recommended, and it is expected that most projects will require programs to use lint as part of the official acceptance procedure.

It should be noted that the best way to use lint is not as a barrier that must be overcome before official acceptance of a program, but rather as a tool to use during and after changes or additions to the code. Lint can find obscure bugs and insure portability before problems occur. Many messages from lint really do indicate something wrong. One fun story is about is about a program that was missing an argument to 'fprintf'.

	fprintf ("Usage: foo -bar <file>\n");
The author never had a problem. But the program dumped core every time an ordinary user made a mistake on the command line. Many versions of lint will catch this.

Most options are worth learning. Some options may complain about legitimate things, but they will also pick up many botches. Note that -p (11) checks function-call type-consistency for only a subset of library routines, so programs should be linted both with and without -p for the best "coverage".

Lint also recognizes several special comments in the code. These comments both shut up lint when the code otherwise makes it complain, and also document special code.


11. Flag names may vary.


upcontents previousSpecial Considerations nextMake