DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
lint analyzer

lint analyzer

This chapter describes the program analyzer, lint(CP). It is organized as follows:

The lint(CP) analyzer checks for code constructs that may cause your C program not to compile, or to execute with unexpected results. lint issues the error and warning messages produced by the C compiler. It also issues ``lint-specific'' warnings about potential bugs and portability problems.

In particular, lint compensates for separate and independent compilation of files in C by flagging inconsistencies in definition and use across files, including any libraries you have used. In a large project environment especially, where the same function may be used by different programmers in hundreds of separate modules of code, lint can help discover bugs that otherwise might be difficult to find. A function called with one less argument than expected, for example, looks at the stack for a value the call has never pushed, with results correct in one condition, incorrect in another, depending on whatever happens to be in memory at that stack location. By identifying dependencies like this one, and dependencies on machine architecture as well, lint can improve the reliability of code run on your machine or someone else's.

Options and directives

lint is a static analyzer, which means that it cannot evaluate the run-time consequences of the dependencies it detects. Certain programs may contain hundreds of unreachable break statements, and lint will give a warning for each of them. The shear number of lint messages issued can be distracting. lint, however, provides command line options and directives to help suppress warnings you consider to be spurious.


NOTE: Directives are special comments embedded in the source text.

For the example we've cited here,

``Using lint'' details options and directives and introduces the lint filter technique, which lets you tailor lint's behavior even more finely to your project's needs. It also shows you how to use lint libraries to check your program for compatibility with the library functions you have called in it.

lint and the compiler

Nearly five hundred diagnostic messages are issued by lint. However, this chapter only describes those lint-specific warnings that are not issued by the compiler. Additionally, this chapter lists diagnostics issued both by lint and the compiler that are capable of being suppressed only by lint options. For the text and examples of all messages issued exclusively by lint or subject exclusively to its options, refer to ``Understanding lint-specific messages''. For the messages also issued by the compiler, consult ``C compiler diagnostics''.

Message formats

Most of lint's messages are simple, one-line statements printed for each occurrence of the problem they diagnose. Errors detected in included files are reported multiple times by the compiler but only once by lint, no matter how many times the file is included in other source files. Compound messages are issued for inconsistencies across files and, in a few cases, for problems within them as well. A single message describes every occurrence of the problem in the file or files being checked. When use of a lint filter requires that a message be printed for each occurrence, compound diagnostics can be converted to the simple type by invoking lint with the -s option.


NOTE: For more information see ``Using lint''.


Next topic: What lint does

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003