Index of Section 1 Manual Pages
| Interix / SUA | lint.1 | Interix / SUA |
LINT(1) System General Commands Manual LINT(1)
NAME
lint - a program for C language source code checking
SYNOPSIS
lint [-abceFghHprvVxz] [-s|-t] [-i|-nu] [-Dname[=def]] [-Uname]
[-Idirectory] [-Ldirectory] [-llibrary] [-ooutputfile] file ...
lint [-abceFghHprvVz] [-s|-t] -Clibrary [-Dname[=def]] [-Idirectory]
[-Uname] file ...
DESCRIPTION
The program lint attempts to detect features of the named C program files
that are likely to be errors, may cause errors, may cause errors to go
undetected, to be non-portable, or to be wasteful. It also performs
stricter type checking than most C compilers. During the first phase of
lint the C preprocessor (with the macro symbol lint defined) is run to
allow selected code that may be questionable to be altered or skipped.
Therefore, the lint macro should be treated by the user as a reserved
word for all C language code that will to be checked by lint.
This C language checker can be run by user on the command line. But more
typically for projects with more than a couple of source files the use of
lint will be controlled by a build tool such as make or jam.
OPTIONS
-a Report assignments of long values to variables that are not long.
-aa Additional to -a, report all assignments of integer values to
other integer values which cause implicit narrowing conversion.
-b Report break statements that cannot be reached. The default is
to not report break statements that cannot be reached because
most lex(1) and many yacc(1) outputs produce many such com-
plaints. Note: this setting is the opposite of many other ver-
sions of lint.
-c Complain about casts which have questionable portability.
-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 input
files, including libraries specified with the -l option, for
mutual compatibility.
-Dname[=def]
Define name for cpp(1) (the pre-processor), as if by a #define
directive. If no definition is given, name is defined as 1. See
also -U.
-e Complain about unusual operations on enum-Types and combinations
of enum- and integer-Types.
-F Print pathnames of files. lint normally prints the filename
without the path.
-g Don't print warnings for some extensions of gcc(1) to the C lan-
guage. Currently these are nonconstant initializers in automatic
aggregate initializations, arithmetic on pointer to void, zero
sized structures, subscripting of non-lvalue arrays, 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 underscores 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. Note: this flag setting is the
opposite of some other lint's.
-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.
-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.
-Idirectory
Add directory to the list of directories in which to search for
include files.
-llibrary
Include the lint library llib-llibrary.ln.
-Ldirectory
Search for lint libraries in directory and directory/lint before
searching the standard place.
-n Do not check compatibility against the standard (default)
library.
-ooutputfile
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 compatibility. To pro-
duce 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 Attempt to check portability of code to other dialects of C.
-r In case of redeclarations report the position of the previous
declaration.
-s Strict ANSI C mode. Issue warnings and errors required by ANSI
C. Also do not produce warnings for constructs which behave dif-
ferently 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 traditional 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 architecture (e.g., m68k)
are defined without leading and trailing underscores. The key-
words const, volatile and signed are not available in traditional
C mode (although the alternate keywords 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 run-
ning lint on a subset of files comprising part of a larger pro-
gram).
-Uname Remove any initial definition of name for the preprocessor.
-v Suppress complaints about unused arguments in functions.
-V Print the command lines constructed by the controller program to
run the C preprocessor and lint's first and second pass.
-x Report variables referred to by extern declarations, but never
used.
-z Do not complain about structures that are never defined (for
example, using a structure pointer without knowing its contents).
BEHAVIOR
Filename arguments ending with .c are understood to be C source files.
Header files (ending in .h) are not to be specified because they will be
discovered as the C code #include's these files. Filenames with names
ending with .ln are understood to be lint processed files from an earlier
invocation of lint. Files ending in .ln are the result of using one of
the options -C, -i, or -o options. The .ln files are analogous to .o
(object) files produced by a compiler using .c files. Special lint
libraries are to be specified with the -l option. These special lint
libraries contain definitions of certain system library and header proto-
types, definitions and declarations not specified with the immediate C
code files.
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
default lint library (llib-lc.ln) (when it can be found; x-ref LIBDIR) 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 com-
plaint 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.
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.
SPECIAL DIRECTIVES
lint's first pass reads standard C source files. lint recognizes the
following C comments as lint 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
option for the next function).
/* CONSTCOND */ or /* CONSTANTCOND */ or /* CONSTANTCONDITION */
suppress complaints about constant operands for the next
expression.
/* 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-
ing occurred.
/* 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.
EXAMPLES
The following are some small examples of using lint from the command line
and with make(1).
Single File
lint foo.c
Single File with additional packages
lint -I/usr/local/include foo.c
Multiple Files
lint -i bar.c foo.c
lint bar.ln foo.ln
Multiple Files with additional packages
lint -I/usr/local/include -i bar.c foo.c
lint bar.ln foo.ln
Single X11 File
lint fooX11.c -lX11
Make Recipe
SRCS= bar.c foo.c
LNS= ${SRCS:.c=.ln}
$(LNS): $(SRCS)
lint -I ../../include -i ${@:.ln=.c}
lint: $(LNS)
lint $>
ENVIRONMENT
LIBDIR directory where the lint libraries specified by -llibrary
must exist. The default path /usr/local/libdata/lint will be
used to search for the libraries when this environment vari-
able is not set.
TMPDIR temporary directory where intermediate files reside.
FILES
/usr/local/libexec/lint1 first pass program
/usr/local/libexec/lint2 second pass program
/usr/local/libdata/lint/llib-lc.ln
prebuilt (default) lint library
/usr/local/libdata/lint/llib-lX11.ln
prebuilt X11 lint library
LINT LIBRARIES
Currently two lint libraries are included: "C" and "X11". The "C" library
(llib-lc.ln) encapsulates all of the functions shipped with Interix
except for the X11 libraries. This includes the traditional C library as
well as the libraries for pthreads, crypt, curses, rpc, sockets, xti, lex
and yacc. The "X11" library (llib-lc.ln) encapsulates the majority of
the X11 family such as X11, Xt, Xmu, Xpm, rgb, Xi, Xext, ICE, Xaw, Xau,
FS, etc. Additional libraries are available upon request (i.e. Motif if
you have purchased the Motik SDK).
SEE ALSO
cc(1), c89(1), cpp(1), gcc(1), jam(1), make(1)
CAVEATS
Some function calls with a program are never intended to be returned
from. The API's exit(3) and longjmp(3) are good examples of such func-
tions. In many standard utilities a call to usage() will not be returned
from. In these situations the specialized C comment "/* NOTREACHED */"
should follow the specific line in the C source code to supress lint from
giving a warning about the code.
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.
The functionality of the options to lint may vary from other instances of
the utility. This due to their different heritages.
SUPPORT
For support or to request additional enhancements please contact .
BSD September 8, 2004 BSD