| LINT(1) | General Commands Manual | LINT(1) |
lint — a C program
verifier
lint |
[-abceFgHhPprTVvwxz] [-i
| -nu] [-S |
-s | -t |
-Ac11 | -Ac23]
[-B directory]
[-D
name[=def]]
[-d directory]
[-I directory]
[-L directory]
[-MD] [-l
library] [-o
outputfile] [-q
id[,id]...]
[-U name]
[-W cppwarnarg]
[-X
id[,id]...]
[-Z cpparg]
file ... |
lint |
[-abceFgHhprTVvwz] [-S |
-s | -t |
-Ac11 | -Ac23]
-C library
[-B directory]
[-D name[=def]]
[-d directory]
[-I directory]
[-MD] [-R
old=new]
[-U name]
[-W cppwarnarg]
[-X
id[,id]...]
[-Z cpparg]
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 performs stricter type checking than traditional
pre-C90 C compilers. The list of errors and warnings that
lint produces are enumerated in
lint(7).
In the first synopsis form, lint checks
each given file as a separate translation unit.
In the second synopsis form, lint
cross-checks the results of the first synopsis form for inconsistencies
between translation units.
lint runs the C preprocessor
as its first phase, with the following preprocessor symbols defined to allow
certain questionable code to be altered or skipped:
__LINT__,
lint,
__lint,
__lint__.
These symbols should therefore be thought of as reserved words for all code
that is to be checked by lint.
Filename arguments ending with .c are
taken to be C source files. Filename arguments ending with
.ln are taken to be the result of an earlier
invocation of lint, with either the
-i, -o or
-C option in effect. 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 variables.
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 standard 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 but always exits successfully. At this point, if a
complaint stems not from a given source file, but from one of its included
files, the source filename will be printed followed by a question mark.
-Ac11-Ac23-a-aa-a, report
all
assignments of integer values to other integer values which cause implicit
narrowing conversion.-B
path-b-C
librarylint 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 input files, including
libraries specified with the -l option, for mutual
compatibility.-c-D
name[=def]#define directive. If no definition is given,
name is defined as 1.-d
directory-e-Flint normally prints the filename without the
path.-g-g flag also turns on some GCC-specific keywords
such as
asm or
typeof.-H-h-I
directory-ilint's first pass only, and are not checked for
compatibility between functions.-L
directory-l
library-MD-MD to
cpp(1), causing cpp to create
files containing dependency information for each source file.-n-o
outputfilelint'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 compatibility. To produce a
llib-llibrary.ln
without extraneous messages, use of the -u option
is suggested. The -v option is useful if the
source file(s) for the lint library are just external interfaces.-P-p-q
id[,id]...make LINT="lint
-q3,5,7" source.ln-R
old=new-r-S-s-s flag, __STRICT_ANSI__
is a predefined preprocessor macro.-T-t__STDC__ is not predefined in
this mode. Warnings are printed for constructs not allowed in traditional
C. Warnings for constructs which behave differently in traditional C and
C90 are suppressed. Preprocessor macros describing the machine type (e.g.
sun3) and machine architecture (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 alternative keywords
with leading underscores still are).-U
name-ulint on a subset of files comprising part of a
larger program).-Vlint's first and second
pass.-v-W
cppwarnarg-w-X
id[,id]...-x-Z
cpparg-Z cppargs can be passed in
the order they are received.-zlint's first pass reads standard C source
files. lint recognizes the following C comments as
commands.
/*
ARGSUSED n */lint check only the first
n parameters for usage; a missing
n is taken to be 0 (this option acts like the
-v option for the next function)./*
BITFIELDTYPE *//* FALLTHRU
*/ or /* FALLTHROUGH
*//*
LINTLIBRARY *//*
LINTED n [comment]
*/ or /*
NOSTRICT n [comment]
*//* LONGLONG
*//* NOTREACHED
*//*
PRINTFLIKE n
*/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./*
PROTOLIB n */lint to treat function declaration
prototypes as function 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./*
SCANFLIKE n */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./*
VARARGS n */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 option), 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 linted.
The lint utility exits 0 on
success, and >0 if an error occurs. If the
-w flag is given, warnings are considered
errors.
LIBDIR-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.LINT_KEEP_CPPOUTyes’, or if set to
‘on-error’ and
lint exits unsuccessfully, do no delete the output
from the C preprocessor, allowing for manual inspection.TMPDIRlint stores temporary
files.CClint -i
-Sg source.clint in C99 mode with GNU extensions, with
only few checks, creating source.ln.lint -i
-abcFghprSxz source.clint with the same checks as in the NetBSD
build.lint -i
-Ac11 -g
-aabceFhpPrTxz source.clint in C11 mode with GNU extensions, enabling
all available checks, including lossy conversions on small integer types,
unusual operations on enum types, more portability warnings, and strict
bool mode.Jochen Pohl (1995)
Roland Illig (2021 to 2025)
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.
| April 10, 2025 | NetBSD 11.0 |