lint(1) DG/UX 5.4.2 lint(1)
NAME
lint - a C program checker
SYNOPSIS
lint [ option ... ] file ...
DESCRIPTION
Lint 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 does the compiler. Lint detects unreachable
statements, loops not entered at the top, automatic variables
declared and not used, and logical expressions whose value is
constant. It also checks for 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 used
but not 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 generate warnings and are ignored.
Lint processes all the .c, .ln, and llib-lx.ln (specified by -lx)
files in their command line order. By default, lint appends the
standard C lint library (llib-lc.ln) to the end of the list of files.
(In a COFF environment, the -p option causes the portable C lint
library (llib-port.ln) to be appended instead.) 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.
OPTIONS
Lint is sensitive to the target environment (see sde-target(1) and
sde(5)): lint options that are accepted only in an ELF target
environment are noted below.
Lint recognizes many cc(1) and cpp(1) command line options, including
-D, -U, -g, and -O, although -g and -O are ignored. In an ELF target
environment, the cc options -Xa, -Xc, and -Xt can be used to indicate
to lint the degree of ANSI conformance to be found in the source.
When coding to the ANSI C standard in a COFF target environment, you
may wish to run lint in an ELF environment with the appropriate
option.
You can use any number of lint options, in any order, intermixed with
file-name arguments. The following options suppress certain kinds of
complaints:
-a Suppress complaints about assignments of long values to
variables that are not long.
-b Suppress complaints about break statements that cannot be
Licensed material--property of copyright holder(s) 1
lint(1) DG/UX 5.4.2 lint(1)
reached. (Programs produced by lex or yacc will often result
in many such complaints).
-h Do not apply heuristic tests that try to find bugs, improve
style, and reduce waste.
-u 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).
-v Suppress complaints about unused arguments in functions.
-x Do not report variables referred to by external declarations
but never used.
-m Suppress complaints about external symbols that could be
declared static (ELF environment only).
The following arguments alter lint's behavior. Some of these option
settings are also available through lint comments (see below).
-lx Include the 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. You can use this option to
reference local lint libraries and to develop multi-file
projects.
-Ldirectory
Look in directory first for libraries, then go to /usr/lib
libraries not found in directory. You can specify several
directories by giving the -L option and a directory name for
each directory you want searched.
-n Do not check compatibility against either the standard or the
portable lint library.
-p Check portability to other dialects 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.
-c 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.
-o lib Cause lint to create a lint library with the name llib-
llib.ln. The -c option nullifies the -o option. The lint
library produced is the input that is given to lint's second
pass. The -o option simply saves this file in the named lint
library. To produce a llib-llib.ln without extraneous
messages, use the -x option. The -v option is useful if the
Licensed material--property of copyright holder(s) 2
lint(1) DG/UX 5.4.2 lint(1)
source file(s) for the lint library are just external
interfaces (for example, the way the file llib-lc is written).
These arguments are accepted only in an ELF environment:
-Idir Search for included header files in the directory dir before
searching the current directory and/or the standard place.
-s Produce one-line diagnostics only. lint occasionally buffers
messages to produce a compound report.
-k Alter the behavior of /*LINTED [message]*/ directives.
Normally, lint will suppress warning messages for the code
following these directives. Instead of suppressing the
messages, lint prints an additional message containing the
comment inside the directive.
-y Specify that the file being linted will be treated as if the
/*LINTLIBRARY*/ directive had been used. A lint library is
normally created by using the /*LINTLIBRARY*/ directive.
-F Print pathnames of files. lint normally prints the filename
without the path.
-V Write to standard error the product name and release.
-Wfile Write a .ln file to file, for use by cflow(1).
-Rfile Write a .ln file to file, for use by cxref(1).
Unrecognized options are warned about and ignored. The predefined
macro lint is defined to allow certain questionable code to be
altered or removed for lint. Thus, the symbol lint should be thought
of as a reserved word for all code that is planned to be checked by
lint.
Certain conventional comments in the C source will change the
behavior of lint:
/*NOTREACHED*/ Stops comments about unreachable code. (This
comment is typically placed just after calls to
functions like exit(2)).
/*VARARGSn*/ Suppresses the usual checking for variable numbers
of arguments in the following function declaration.
The data types of the first n arguments are checked;
a missing n is taken to be 0.
/*ARGSUSED*/ Turns on the -v option for the next function.
/*LINTLIBRARY*/ At the beginning of a file, shuts off complaints
about unused functions and function arguments in
this file. Equivalent to using the -v and -x
options.
Licensed material--property of copyright holder(s) 3
lint(1) DG/UX 5.4.2 lint(1)
These comments are recognized only in an ELF environment:
/*CONSTCOND*/ or /*CONSTANTCOND*/ or /*CONSTANTCONDITION*/
suppresses complaints about constant operands for
the next expression.
/*EMPTY*/ suppresses complaints about a null statement
consequent on an if statement. This directive
should be placed after the test expression, and
before the semicolon. This directive is supplied to
support empty if statements when a valid else
statement follows. It suppresses messages on an
empty else consequent.
/*FALLTHRU*/ or /*FALLTHROUGH*/
suppresses complaints about fall through to a case
or default labeled statement. This directive should
be placed immediately preceding the label.
/*LINTED [message]\(**/
suppresses any intra-file warning except those
dealing with unused variables or functions. This
directive should be placed on the line immediately
preceding where the lint warning occurred. The -k
option alters the way in which lint handles this
directive. Instead of suppressing messages, lint
will print an additional message, if any, contained
in the comment. This directive is useful in
conjunction with the -s option for post-lint
filtering.
/*PRINTFLIKEn*/ makes lint check the first (n-1) arguments as usual.
The nth argument is interpreted as a printf format
string that is used to check the remaining
arguments.
/*PROTOLIBn*/ causes lint to treat function declaration prototypes
as function definitions if n is non-zero. This
directive can be used only in conjunction with the
/* LINTLIBRARY */ directive. If n is zero, function
prototypes will be treated normally.
/*SCANFLIKEn*/ makes lint check the first (n-1) arguments as usual.
The nth argument is interpreted as a scanf format
string that is used to check the remaining
arguments.
Lint produces its output in three phases. In the first, it prints
messages for each source file. In the second phase, it prints
messages for any files included with #include. In the final phase,
it prints messages about interrelations between files. Question
marks after filenames in this phase indicate lint could not determine
exactly what file the message refers to. The third phase is not done
if the -c is given.
Licensed material--property of copyright holder(s) 4
lint(1) DG/UX 5.4.2 lint(1)
The behavior of the -c and the -o options allows for incremental use
of lint on a set of C source files. You can invoke lint once for
each source file with the -c option. Each of these invocations
produces a .ln file that corresponds to the .c file, and prints all
messages about that source file only. After .ln files have been
produced, for all the source files, lint 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 lets you use make to lint
only the source files that have been modified since the last time the
set of source files were linted.
FILES
/usr/lib The directory where the lint libraries
specified by the -lx option must exist;
usually /usr/lib
LIBDIR/lint[12] First and second passes
LIBDIR/llib-lc.ln Declarations for C Library functions (binary
format; if you have bought a source license,
the source is in LIBDIR/llib-lc)
LIBDIR/llib-port.ln Declarations for portable functions (binary
format; if you have a source license, the
source is in LIBDIR/llib-port)
LIBDIR/llib-lm.ln Declarations for Math Library functions
(binary format; if you have a source license,
the source is in LIBDIR/llib-lm)
/usr/tmp/*lint* Temporaries
SEE ALSO
cc(1), cpp(1), cscope(1), make(1), sde-target(1), sde(5),
Programmer's Guide: ANSI C and Programming Support Tools.
NOTES
Exit(2), longjmp(3C), and other functions that do not return are not
understood; this causes various problems.
Licensed material--property of copyright holder(s) 5