LINT(1,C) AIX Commands Reference LINT(1,C)
-------------------------------------------------------------------------------
lint
PURPOSE
Checks C programs for potential problems.
SYNTAX
+-----------------+
lint ---| +-------------+ |--- file ---|
+-| -a -lkey -u |-+ ^ |
^| -b -n -c -v || +--------+
|| -h -p -x ||
|| -Nnnum -z ||
|| -o lib ||
|| -T file ||
|+-------------+|
+---------------+
Note: This command does not have MBCS support.
DESCRIPTION
The lint program checks C-language source code for coding and syntax errors and
for inefficient or nonportable code. You can use this program to
o Identify source code and library incompatibility
o Enforce type checking rules more strictly than the compiler
o Identify potential problems with variables
o Identify potential problems with functions
o Identify problems with flow control
o Identify legal constructions that may produce errors or be inefficient
o Identify possibly nonportable code.
The lint command assumes that file names ending in .c are C Language source
files. It assumes that those ending in .ln are the result of an earlier
running of lint with either the -c or the -o flag used. These .ln files are
analogous to the .o (object) files produced by the cc command when given a .c
file as input. The lint command warns you about files with other suffixes and
ignores them.
The lint command takes all the .c and .ln files and the libraries specified by
-l flags and processes them in the order that they appear on the command line.
By default, it adds the standard lint library (llib-lc.ln) to the end of the
list of files. However, when you select the -p flag, lint uses the portable
library llib-port.ln. By default, the second pass of lint checks this list of
Processed November 8, 1990 LINT(1,C) 1
LINT(1,C) AIX Commands Reference LINT(1,C)
files for mutual compatibility; however, if you specify the -c flag, lint
ignores the .ln and lib-lx files.
The -c and -o flags allow for incremental use of the lint command on a set of C
Language source files. Generally, you use lint once for each source file with
the -c flag. Each of these runs produces a .ln file that corresponds to the .c
file and writes all messages that pertain to that source file only. After you
run all source files separately through lint, you run the command again,
without the -c flag, listing all the .ln files with the needed -l arguments.
This writes all inter-file inconsistencies. This procedure works well with the
make command, allowing it to run lint on only those source files that have been
modified since the last time that set of source files was checked.
The following comments in a C source program change the way that the lint
command operates when checking the source program:
/*NOTREACHED*/ Suppresses comments about unreachable code.
/*VARARGSn*/ Suppresses checking the following function declaration for
varying numbers of arguments but does check the data type of
the first n arguments. If you do not include a value for n,
lint checks no arguments (n=0).
/*ARGSUSED*/ Turns on the -v flag for the next function.
/*LINTLIBRARY*/ If you place this comment at the beginning of a file, lint
does not identify unused functions in the file.
The lint command first writes messages about each source file as it processes
the file. It collects messages about included files and writes those after it
has gone through all the source files. Finally, if you have not specified the
-c flag, it collects information gathered from all input files and checks it
for consistency. At this point, if it is not clear whether a message stems
from a given source file or from one of its included files, lint displays the
source file name followed by a question mark.
FLAGS
-a Suppresses messages about assignments of long values to
variables that are not long.
-b Suppresses messages about unreachable break statements.
-h Does not try to detect bugs, improve style, or reduce waste.
-c Causes lint to produce a .ln file for every .c file on the
command line. These .ln files are the product of the first pass
of lint only and are not checked for inter-function
compatibility.
Processed November 8, 1990 LINT(1,C) 2
LINT(1,C) AIX Commands Reference LINT(1,C)
-lkey Includes the additional lint library llib-lkey.ln. You can
include a lint version of the math library llib-lm.ln by
specifying -lm on the command line or llib-ldos.ln by specifying
-ldos on the command line. Use this flag to include local lint
libraries when checking files that are part of a project having
a large number of files. This flag does not prevent lint from
using the llib-lc.ln library.
-n Does not check for compatibility with either the standard or the
portable lint libraries.
-Nnnum Increases the size of the symbol table. The default size is
1500.
-o lib Causes lint to create a lint library with the name llib-llib.ln.
The -c flag nullifies any use of the -o flag. The lint library
produced is the input that is given to the second pass of lint.
The -o flag simply causes this file to be saved in the named
lint library. To produce a llib-llib.ln without extraneous
messages, use the -x flag. The -v flag is useful if the source
files for the lint library are just external interfaces (for
example, the way the file llib-lc is written). These flag
settings are also available through the use of lint comment
lines.
-p Checks for portability to other C dialects.
-T file Use file as intermediate file.
-u Suppresses messages about functions and external variables that
are either used and not defined or defined and not used. Use
this flag to run lint on a subset of files of a larger program.
-v Suppresses messages about function parameters that are not used.
-x Suppresses messages about variables that have external
declarations but are never used.
-z Suppresses messages about undeclared structures.
In addition, the lint command recognizes the following flags of the cpp command
(macro preprocessor):
-Dname[=def] Defines the name, as if by a #define directive. The default
def is 1.
-Idir Adds dir to the list of directories in which lint searches
for #include files.
-Uname Removes any initial definition of name, where name is a
reserved symbol that is predefined by the particular
preprocessor.
Processed November 8, 1990 LINT(1,C) 3
LINT(1,C) AIX Commands Reference LINT(1,C)
EXAMPLES
1. To check a C program for errors:
lint program.c
2. To suppress some of the messages:
lint -v -x program.c
This command checks "program.c", but does not display error messages about
unused function parameters (-v) or unused externals (-x).
3. To check the program against an additional lint library:
lint -lsubs program.c
This command checks "program.c" against both the standard lint library
/usr/lib/llib-lc.ln and /usr/lib/llib-l"subs".ln.
4. To check against the portable library and an additional library:
lint -lsubs -p program.c
This command checks "program.c" against both the portable lint library
/usr/lib/llib-port.ln and /usr/lib/llib-l"subs".ln.
5. To check against a nonstandard library only:
lint -lsubs -n program.c
This command checks "program.c" against only /usr/lib/llib-l"subs".ln.
FILES
/usr/lib/lint[12] Programs.
/usr/lib/llib-lc.ln Declarations for standard functions (binary format).
/usr/lib/llib-lc Declarations for standard functions (source).
/usr/lib/llib-port.ln Declarations for portable functions (binary format).
/usr/lib/llib-port Declarations for portable functions (source).
/usr/lib/llib-lm.ln Declarations for standard math functions (binary
format).
/usr/lib/llib-lm Declarations for standard math functions (source).
/usr/lib/llib-ldos.ln Declarations for DOS Services functions (binary
format).
/usr/lib/llib-ldos Declarations for DOS Services functions (source).
/usr/tmp/*lint* Temporary files.
RELATED INFORMATION
See the following command: "cc."
Processed November 8, 1990 LINT(1,C) 4
LINT(1,C) AIX Commands Reference LINT(1,C)
See "Checking C Programs" in AIX Operating System Programming Tools and
Interfaces.
See "Overview of International Character Support" in Managing the AIX Operating
System.
Processed November 8, 1990 LINT(1,C) 5