Search all pages
Professions, Sciences, Humanities, Business, ...
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Conversions, tests, processing, manipulation,...
Integer, Floating point, Matrix, Statistics, Boolean, ...
Algorithms, Memory, Process control, Debugging, ...
Data storage, Integrity, Encryption, Compression, ...
Networks, protocols, Interprocess, Remote, Client Server, ...
Timing, Calendar and Clock, Audio, Video, Printer, Controls...
Management, Filtering, File & Directory access, Viewers, ...
RocketLink!--> Man page versions:
LINT(1) OpenBSD Reference Manual LINT(1)
lint - a C program verifier
lint [-abceghprvxzHFV] [-s|-t] [-i|-nu] [-Dname[=def]] [-Uname]
[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile] file ...
lint [-abceghprvzHFV] [-s|-t] -Clibrary [-Dname[=def]] [-Idirectory]
[-Uname] file ...
lint attempts to detect features of the named C program files that are
likely to be bugs, to be non-portable, or to be wasteful. It also per-
forms stricter type checking then does the C compiler. lint runs the C
preprocessor as its first phase, with the preprocessor symbol lint de-
fined to allow certain questionable code to be altered or skipped by
lint. Therefore, this symbol should be thought of as a reserved word for
all code that is to be checked by lint.
Among the possible problems that are currently noted are unreachable
statements, loops not entered at the top, variables declared and not
used, and logical expressions with constant values. Function calls are
checked for inconsistencies, such as calls to functions that return val-
ues in some places and not in others, functions called with varying num-
bers of arguments, function calls that pass arguments of a type other
than the type the function expects to receive, functions whose values are
not used, and calls to functions not returning values that use the non-
existent return value of the function.
Filename arguments ending with .c are taken to be C source files. File-
name arguments with names ending with .ln are taken to be the result of
an earlier invocation of lint, with either the -i, -o or -C option in ef-
fect. The .ln files are analogous to the .o (object) files produced by
cc(1) from .c files. lint also accepts special libraries specified with
the -l option, which contain definitions of library routines and vari-
lint takes all the .c, .ln, and llib-llibrary.ln (lint library) files and
processes them in command-line order. By default, lint appends the stan-
dard C lint library (llib-lc.ln) to the end of the list of files. When
the -i option is used, the .ln files are ignored. Also, when the -o or
-i options are used, the llib-llibrary.ln files are ignored. When the -i
option is omitted the second pass of lint checks this list of files for
mutual compatibility. At this point, if a complaint stems not from a giv-
en source file, but from one of its included files, the source filename
will be printed followed by a question mark.
-a Report assignments of long values to variables that are not
-aa Additional to -a, report all assignments of integer values to
other integer values which cause implicit narrowing conver-
-b Report break statements that cannot be reached. This is not
the default because, unfortunately, most lex(1) and many
yacc(1) outputs produce many such complaints.
-c Complain about casts which have questionable portability.
-e Complain about unusual operations on enum-Types and combina-
tions of enum- and integer-Types.
-g Don't print warnings for some extensions of gcc(1) to the C
language. Currently these are nonconstant initializers in au-
tomatic aggregate initializations, arithmetic on pointer to
void, zero sized structures, subscripting of non-lvalue ar-
rays, prototypes overriding old style function declarations
and long long integer types. The -g flag also turns on the
keywords asm and inline (alternate keywords with leading un-
derscores for both asm and inline are always available).
-h Apply a number of heuristic tests to attempt to intuit bugs,
improve style, and reduce waste.
-i 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 compatibility between functions.
-n Do not check compatibility against the standard library.
-p Attempt to check portability of code to other dialects of C.
-r In case of redeclarations report the position of the previous
-s Strict ANSI C mode. Issue warnings and errors required by AN-
SI C. Also do not produce warnings for constructs which be-
have differently in traditional C and ANSI C. With the -s
flag, __STRICT_ANSI__ is a predefined preprocessor macro.
-t Traditional C mode. __STDC__ is not predefined in this mode.
Warnings are printed for constructs not allowed in tradition-
al C. Warnings for constructs which behave differently in
traditional C and ANSI C are suppressed. Preprocessor macros
describing the machine type (e.g. sun3) and machine archi-
tecture (e.g. m68k) are defined without leading and trailing
underscores. The keywords const, volatile and signed are not
available in traditional C mode (although the alternate key-
words with leading underscores still are).
-u Do not complain about functions and external variables used
and not defined, or defined and not used (this is suitable
for running lint on a subset of files comprising part of a
-v Suppress complaints about unused arguments in functions.
-x Report variables referred to by extern declarations, but nev-
-z Do not complain about structures that are never defined (for
example, using a structure pointer without knowing its con-
-Clibrary Create a lint library with the name llib-llibrary.ln. This
library is built from all .c and .ln input files. After all
global definitions of functions and variables in these files
are written to the newly created library, lint checks all in-
put files, including libraries specified with the -l option,
for mutual compatibility.
Define name for cpp(1), as if by a #define directive. If no
definition is given, name is defined as 1.
Add directory to the list of directories in which to search
for include files.
-llibrary Include the lint library llib-llibrary.ln.
Search for lint libraries in directory and directory/lint be-
fore searching the standard place.
-F Print pathnames of files. lint normally prints the filename
without the path.
-H If a complaint stems from an included file lint prints the
name of the included file instead of the source file name
followed by a question mark.
Name the output file outputfile. The output file produced is
the input that is given to lint's second pass. The -o option
simply saves this file in the named output file. If the -i
option is also used the files are not checked for compatibil-
ity. To produce a llib-llibrary.ln without extraneous mes-
sages, use of the -u option is suggested. The -v option is
useful if the source file(s) for the lint library are just
-Uname Remove any initial definition of name for the preprocessor.
-V Print the command lines constructed by the controller program
to run the C preprocessor and lint's first and second pass.
lint's first pass reads standard C source files. lint recognizes the
following C comments as commands.
/* ARGSUSEDn */
makes lint check only the first n arguments for usage; a
missing n is taken to be 0 (this option acts like the -v op-
tion for the next function).
/* CONSTCOND */ or /* CONSTANTCOND */ or /* CONSTANTCONDITION */
suppress complaints about constant operands for the next ex-
/* FALLTHRU */ or /* FALLTHROUGH */
suppress complaints about fall through to a case or default
labelled statement. This directive should be placed immedi-
ately preceding the label.
/* LINTLIBRARY */
At the beginning of a file, mark all functions and variables
defined in this file as used. Also shut off complaints about
unused function arguments.
/* LINTED [comment] */ or /* NOSTRICT [comment] */
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 warn-
/* LONGLONG */
Suppress complaints about use of long long integer types.
/* NOTREACHED */
At appropriate points, inhibit complaints about unreachable
code. (This comment is typically placed just after calls to
functions like exit(3)).
/* PRINTFLIKEn */
makes lint check the first (n-1) arguments as usual. The n-th
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 func-
tion definitions if n is non-zero. This directive can only be
used 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 n-th
argument is interpreted as a scanf format string that is used
to check the remaining arguments.
/* VARARGSn */
Suppress 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.
The behavior of the -i 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 -i option. Each of these invocations produces a
.ln file that 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 -i op-
tion), listing all the .ln files with the needed -llibrary options. this
will print all the inter-file inconsistencies. This scheme works well
with make(1); it allows make(1) to be used to lint only the source files
that have been modified since the last time the set of source files were
LIBDIR the directory where the lint libraries specified by the
-llibrary option must exist. If this environment variable is
undefined, then the default path /usr/libdata/lint will be
used to search for the libraries.
TMPDIR usually the path for temporary files can be redefined by set-
ting this environment variable.
/usr/libdata/lint/llib-l*.ln various prebuilt lint libraries
cc(1), cpp(1), make(1)
The routines exit(3), longjmp(3) and other functions that do not return
are not understood; this causes various incorrect diagnostics.
Static functions which are used only before their first extern declara-
tion are reported as unused.
Libraries created by the -o option will, when used in later lint runs,
cause certain errors that were reported when the libraries were created
to be reported again, and cause line numbers and file names from the
original source used to create those libraries to be reported in error
messages. For these reasons, it is recommended to use the -C option to
create lint libraries.
OpenBSD 2.6 August 28, 1994 5
Source: OpenBSD 2.6 man pages. Copyright: Portions are copyrighted by BERKELEY
SOFTWARE DESIGN, INC., The Regents of the University of California, Massachusetts
Institute of Technology, Free Software Foundation, FreeBSD Inc., and others.
(Corrections, notes, and links courtesy of RocketAware.com)
FreeBSD Sources for lint(1)
RocketLink!--> Man page versions:
Search | About | Comments | Submit Path: RocketAware >
RocketAware.com is a service of Mib Software
Copyright 1999, Forrest J. Cavalier III. All Rights Reserved.
We welcome submissions and comments