contact us

The Lint Page

Lint is a program for finding errors in C programs. It's a static program analyzer: it reads the source code of your program. The output of lint is a list of warnings or errors.

Lint can help you find errors in your C programs. Since it works from the source code, it doesn't find all errors (it can't predict how the program will work at run time). Typical things it will find:

  • Unused variables, data types, and functions
  • Use of functions without prototypes.
  • Possible empty loops (semi-colons out of place).
  • Truncation on assignment or argument passing
  • Dangerous mixing of data types.

Using lint makes your program more readable, and is educational. You can learn a lot about a language just by understanding what lint is complaining about.

What makes a good lint?

Documentation. The UNIX lint suffers from inadequate documentation. It can be hard to know what it's complaining about. Some UNIX vendors have decent tutorials on lint, but the man page alone is inadequate.

A built-in pre-processor lets lint warn you about

  • Unused header files
  • Unused define directives

Gimpel's product makes up for both of these limitations.

Other features to make the program usable are ones that contribute to it getting out of your way:

  1. Good customization, so you can check for the errors that you consider important.
  2. Fast operation, including the ability to do incremental linting.
  3. Good integration with your development environment.

Isn't lint Obsolete?

Some programmers think that lint is obsolete now we have good C compilers. This isn't so:

  1. Lint finds link errors as well as compile errors.
  2. Lint analyses a group of files. The compiler processes only one.
  3. Compilers are optimized for speed of compilation, and quality of generated code; not for degree of warnings.
  4. Modern lint programs analyze C++ as well as C.

The element of truth in the critics' argument is:

  1. Your compiler's error messages should not be ignored. The first thing you should do is set the warnings as verbose as you can stand.
  2. The UNIX version of lint has not been updated to handle C++ and is slated for obsolescence.
  3. The lint vendors really haven't addressed IDE integration well, but then the whole tools industry hasn't addressed this issue. Lint was created in the era when the command line was the common standard for tool interaction. Lint was designed to stand in for the C compiler in a make file. Now we're stuck with proprietary IDE's with limited built-in make engines, integrating lint is a lot harder. On the other hand, you don't have to mess with "make."

Where Can I Get Lint?

Some lint programs:

  • UNIX lint normally comes with the C development package for your OS.
  • You can download LCLint for Windows 95/NT and for Linux. There's an article on LCLint from Issue 51 of Linux Gazette.
  • PC-Lint from Gimpel Software is a commercial package. It's available for the PC and for various flavors of UNIX (you compile the obsfucated source code).
  • CodeCheck from Abraxas Software. Not really a classic lint, it's a programmable static analyzer that's actually more useful for coding standards compliance checking.
home | about | products | services | links | contact us

Copyright © 2000-2013, Elirion, Inc. All rights reserved.
Send comments on this site to our