Content-type: text/html Man page of lint

lint

Section: User Commands (1)
Index Return to Main Contents
 

NAME

lint - a C program checker  

SYNOPSIS

lint [-abchlnpuxv] [-cpp] [-dpath] [-Dname[=definition]] [-Idirectory] [-lkey] [-olibrary] [-MA] [-Msuboptions] [-stdn] [-Pppoptions] [-Qsuboptions] [-Ndnumber] [-Nlnumber] [-Nnnumber] [-Ntnumber] [-Uname] [-wclass...] [-Xdollar] [-XEnum] file...


 

OPTIONS

Any number of lint options may be used, in any order, intermixed with file-name arguments. The following options are used to suppress certain kinds of complaints: Suppress complaints about assignments of long values to variables that are not long. Suppress complaints about break statements that cannot be reached. (Programs produced by lex or yacc will often result in many such complaints). Do not apply heuristic tests that attempt to intuit bugs, improve style, and reduce waste. Suppress complaints about functions and external variables used and not defined, or defined and not used. (This option is suitable for running lint on a subset of files of a larger program). Suppress complaints about unused arguments in functions. Do not report variables referred to by external declarations but never used. Suppress complaints about the use of the dollar sign ($) in variable names. Controls the reporting of warning classes. All warning classes are active by default. They can however, be individually activated by including the appropriate option as part of the class argument. For example, to report only declaration consistency and Heuristic complaints, enter the following command: lint -wA -wdh prog.c

In the preceding example, -wA deactivates all warnings and -wdh activates the desired reports. The following list describes available classes of warnings: Non-ANSI features Comparisons with unsigned values Declaration consistency Heuristic complaints Suppresses the following messages: function prototype not in scope and old style argument declaration. Assignment of long values to variables that are not long Null-effect code Unknown order of evaluation Various portability concerns Return statement consistency Proper usage of variables and functions Deactivates all warnings Constants occurring in conditionals Declarations that are never used or defined. Obsolete features Function prototype presence Detection of unreachable code Storage capacity checks Equivalent to -u

The following options alter lint's behavior: Cause lint to use /lib/cpp as its preprocessor instead of /usr/bin/cc. Include additional lint library llib-lx.ln. For example, you can include a lint version of the Math Library llib-lm.ln by inserting -lm on the command line. This argument does not suppress the default use of llib-lc.ln. These lint libraries must be in the assumed directory. This option can be used to reference local lint libraries and is useful in the development of multi-file projects. Do not check compatibility against either the standard or the portable lint library. Do not check compatibility between files or the lint libraries. Attempt to check portability to other dialects (IBM and GCOS) of C. Along with stricter checking, this option causes all non-external names to be truncated to eight characters and all external names to be truncated to six characters and one case. Cause lint to produce a .ln file for every .c file on the command line. These .ln files are the product of lint's first pass only, and are not checked for inter-function compatibility. Cause lint to create a lint library with the name llib-llib.ln. The -c option nullifies any use of the -o option. The lint library produced is the input that is given to lint's second pass. The -o option simply causes this file to be saved in the named lint library. To produce a llib-llib.ln without extraneous messages, use of the -x option is suggested. The -v option is useful if the source file(s) for the lint library are just external interfaces (for example, the way the file llib-lc is written). These option settings are also available through the use of ``lint comments'' (see below). Cause lint to store the files created as a result of the -o or -c option in the specified path. Enforces ANSI C standard rules. The default lint preprocessing and parsing mode is Extended C (K&R). ANSI preprocessing and parsing rules may be selected as an option. ANSI mode prepends (adds at the beginning) the standard ANSI library function prototypes in place of the default extended mode C library. ANSI mode enforces a stricter interfile object reference/definition linkage checking. This option also invokes the -std1 C preprocessor option and defines the macro _ANSI_C_SOURCE. The suboptions enforce some of the ANSI parsing rules. These are implemented as toggles. This option and set of suboptions can be used to turn on or off specific ANSI features. For example, -MAt turns on all ANSI rules except ANSI typing rules. follow ANSI parsing rules follow ANSI const array struct member bug follow ANSI type compatibility rules follow ANSI type promotion rules follow ANSI strict ref/def rules follow ANSI scoping rules for externs follow ANSI typing rules Allows C preprocessor options to be specified when executing the lint command. For example, specifying -PV invokes the preprocessor with the -V option specified. Directs the C Preprocessor to generate the appropriate predefined macros. The -std option causes the macro __STDC__=0 to be passed to the preprocessor; -std1 causes the macro __STDC__=1 to be passed, and -std0 causes __STDC__ to be undefined. The default is -std0. The -std0 option is incompatible with the -M option. If -std or -std1 are selected, the -MA ANSI parsing rules are automatically selected. Specifies the number (num) of errors lint accepts before terminating. By default, lint terminates after encountering 30 errors.

The -Q option provides support for migration from ULTRIX and DEC OSF/1 Version 1.0 systems to DEC OSF/1 Version 1.2 (now known as Tru64 UNIX) and higher versions of the Tru64 UNIX operating system. This option turns on checking for all common programming techniques which might cause problems when moving from 32-bit systems to 64-bit systems. The -Q option disables checking for other programming problems, so this switch should be used only for migration checking.

Suboptions to -Q have the form -Qn. You can enter more than one suboption with the -Q option, for example, -QacP to suppress checking for pointer alignment problems, problematic type casts, and function prototype checks, respectively.

The following suboptions are available to suppress specific categories of checking: Suppresses checking of pointer alignment problems. Suppresses checking for problematic type casts. (Overrides -QG option.) Suppresses checking for format control strings in scanf and printf. Suppresses checking for assignments of long values to variables of a type other than long. Suppresses checking for illegal combinations pointer and integer data types. Suppresses checking for problematic sign extensions to long Suppresses checking to see if a variable is used before it is set. Suppresses checking to see if there is constant truncation of longs in an assignment. Suppresses checking to see if precision has been lost in field assignment. Suppresses truncation message when casting to char *. (Overridden by -Qc option.) Suppresses function prototype checks. Suppresses checking for a problematic combination of structure pointers. If structure checking and cast checking are not suppressed then the casting of differing structures and pointers to structures are flagged if the structures differ in size and/or alignment as described in the following two suboptions. Suppresses warnings about casting a structure or structure pointer to one of a different size. Takes effect only if c and S are not specified on the command line. Suppresses warnings about casting a structure or structure pointer to on of a different alignment. Takes effect only if c and S are not specified on the command line.

The -N option and its related suboptions allow you to increase the size of various internal tables at runtime. Suboptions to the -N option take the form -Nzx where z is a suboption and x is an integer size. Use this option with its suboptions to increase the initial size of various internal tables at runtime if the default values are not sufficient. All of the tables are dynamically expandable; however, larger initial values may improve run-time performance. Use with -N to increase the initial size of the symbol table. To increase the number of entries, use -Nnxxxx to increase the number of entries. Use a number greater than 1500, which is the default value. The larger the number, the fewer collisions. As a rule of thumb, use a number roughly twice the number of source code lines. Use with -N when you encounter the error that the dimension table has overflowed or is full. To increase the number of base elements allocated to the members of the dimension tables, use a number greater than 2000, which is the default value. Use with -N when you encounter the error stating that the parse tree limit has been reached, ``out of tree space; recompile with Ntx option with x greater than xxxx''. Run lint again, do not recompile, on the module that generated the error using -Ntyyyy with yyyy greater than the value in the error message. Use with -N when you encounter the error stating that the local type table limit has been reached, ``out of tree space; recompile with -Nlx option with x greater than xxxx''. Run lint again, do not recompile, on the module that generated the error, using -Nlyyyy with yyyy greater than the value in the error message.

The -D, -U, and -I options of cpp(1) and the -g and -O options of cc(1) are also recognized as separate arguments. The -g and -O options are ignored, but, by recognizing these options, lint's behavior is closer to that of the cc(1) command. Other options are warned about and ignored. The pre-processor symbol ``lint'' is defined to allow certain questionable code to be altered or removed for lint. Therefore, the symbol ``lint'' should be thought of as a reserved word for all code that is planned to be checked by lint.

The following lint directives, which appear as conventional comments in the C source program, change the behavior of lint: Prevents lint from warning against unused function arguments (that is, turns on the -v option) for the next function. When placed at the beginning of a file, suppresses complaints about unused functions and function arguments in this file. This is equivalent to using the -v and -x options. This directive is used for building lint libraries. Permits a standard prototype checking library to be formed from header files by making function prototype declarations appear as function definitions. The /*LINTSTDLIB*/ directive implicitly activates the functions of the /*NOTUSED*/ and /*LINTLIBRARY*/ directives to reduce warning noise levels. When placed in a file, suppresses warnings about all used but undefined external symbols and functions that are subsequently encountered in the file. When placed at appropriate points in a program (typically immediately following a return, break, or continue statement), stops comments about unreachable code. Note that lint does not recognize the exit function and other functions that may not return. When placed in a file, suppresses warnings about all unused external symbols, functions, and function parameters that are subsequently encountered in the file. This directive is similar to the /*LINTLIBRARY*/ directive, although /*NOTUSED*/ also applies to external symbols. Suppresses the usual checking for variable numbers of arguments in the following function declaration. The data types of the first n arguments are checked; for instance, if /*VARARGS2*/ is specified, lint checks only the first two arguments. If n is not specified, it is interpreted as a 0 (zero).

The lint utility produces its first output on a per-source-file basis. Complaints regarding included files are collected and printed after all source files have been processed. Finally, if the -c option is not used, information gathered from all input files is collected and checked for consistency. At this point, if it is not clear whether a complaint stems from a given source file or from one of its included files, the source file name will be printed followed by a question mark.

The behavior of the -c and the -o options allows for incremental use of lint on a set of C source files. Generally, one invokes lint once for each source file with the -c option. Each of these invocations produces a .ln file which corresponds to the .c file, and prints all messages that are about just that source file. After all the source files have been separately run through lint, it is invoked once more (without the -c option), listing all the .ln files with the needed -lx options. This will print all the inter-file inconsistencies. This scheme works well with make(1); it allows make to be used to lint only the source files that have been modified since the last time the set of source files were run through lint.
 

DESCRIPTION

The lint program checker attempts to detect features of the C program files that are likely to be bugs, non-portable, or wasteful. It also checks type usage more strictly than the compilers. Among the things that are currently detected are unreachable statements, loops not entered at the top, automatic variables declared and not used, and logical expressions whose value is constant.

Moreover, the usage of functions is checked to find functions that return values in some places and not in others, functions called with varying numbers or types of arguments, and functions whose values are not used or whose values are used but none returned.

Arguments whose names end with .c are taken to be C source files. Arguments whose names end with .ln are taken to be the result of an earlier invocation of lint with either the -c or the -o option used. The .ln files are analogous to .o (object) files that are produced by the cc(1) command when given a .c file as input. Files with other suffixes produce warnings and are ignored.

The lint program checker will take all the .c, .ln , and llib-lx.ln (specified by -lx) files and process them in their command line order. It appends a lint library file to this list of files, as follows: If the -p option is used, the portable C lint library (llib-port.ln) is appended. If the -std or -std1 option is used, the C standard lint library llib-lcstd.ln) is appended. If the -MA option is used, the ANSI standard lint library (llib-lansi.ln) is appended. Otherwise, the standard C lint library (llib-lc.ln) is appended.

When the -c option is not used, the second pass of lint checks this list of files for mutual compatibility. When the -c option is used, the .ln and the llib-lx.ln files are ignored.
 

RESTRICTIONS

The exit(2), setjmp(3) and other functions that do not return are not understood; this causes various lies.
 

FILES

The directory where the lint libraries specified by the -lx option must exist. The directory where the lint library sources are kept. first and second passes of lint declarations for C Library functions (binary format; source is in llib-lc.c) declarations for portable functions (binary format; source is in llib-port.c) declarations for Math Library functions (binary format; source is in llib-lm.c) declarations for Curses Library functions (binary format; source is in llib-lcrses.c) temporary files (default directory /usr/tmp)
 

SEE ALSO

Commands:  cc(1), cpp(1), make(1)


 

Index

NAME
SYNOPSIS
OPTIONS
DESCRIPTION
RESTRICTIONS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 02:42:50 GMT, October 02, 2010