Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lint(1) — sys5 — Apollo Domain/OS SR10.4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

cpp(1)

make(1)

LINT(1)                              SysV                              LINT(1)



NAME
     lint - a C program checker

SYNOPSIS
     lint [ option ] ... file ...

DESCRIPTION
     lint attempts to detect features of C program files that are likely to be
     bugs, non-portable, or wasteful.  It also checks type usage more strictly
     than the compilers.  Among the things that are currently detected are:

     o  Unreachable statement

     o  Loops not entered at the top

     o  Automatic variables declared and not used

     o  Logical expressions whose value is constant

     o  Functions that return values in some places and not in others

     o  Functions called with varying numbers or types of arguments

     o  Functions whose values are not used or whose values are used but none
        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
     are warned about and ignored.

     lint takes all the .c, .ln, and llib-lx.ln (specified by -lx) files and
     processes them 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.
     However, if the -p option is used, the portable C lint library (llib-
     port.ln) is 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.

     Any number of lint options can be used, in any order, intermixed with
     file-name arguments.

OPTIONS
     Options to Suppress Complaints

     -a        Suppresses complaints about assignments of long values to
               variables that are not long.

     -b        Suppresses complaints about break statements that cannot be
               reached.  (Programs produced by lex or yacc often result in
               many such complaints).

     -h        Does not apply heuristic tests that attempt to intuit bugs,
               improve style, and reduce waste.

     -u        Suppresses 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        Suppresses complaints about unused arguments in functions.

     -x        Does not report variables referred to by external declarations
               but never used.

      Options That Alter lint's Behavior

     -lx       Includes 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.  This option can be used to
               reference local lint libraries and is useful in the development
               of multi-file projects.

     -n        Does not check compatibility against either the standard or the
               portable lint library.

     -p        Attempts to check portability to other dialects (IBM and GCOS)
               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.

     -s        Makes stricter checks about pointer and structure alignments
               that can prevent portability.  Complains about a cast that
               converts a pointer from a less restrictive alignment to a more
               restrictive alignment.  Complains about a structure member that
               is not naturally aligned.

     -c        Causes lint to 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    Causes lint to create a lint library with the name llib-
               llib.ln.  The -c option nullifies any use of the -o option.
               The lint library produced is the input given to lint's second
               pass.  The -o option simply causes this file to be saved 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 source file(s) for the lint library are just
               external interfaces (for example, the way the file llib-lc is
               written).  These option settings are also available through the
               use of "lint comments" (see below).

     -Amode    Specifies the compilation standard to be used by lint.  The
               mode can be one of the following letters:

               xansi          Extended ANSI mode.  Uses the ANSI C
                              preprocessor; issues warnings for function calls
                              not in the scope of a function prototype; allows
                              Domain extensions; does not define the
                              preprocessor symbol lint.  This mode is the
                              default.

               ansi           Strict ANSI mode.  Uses the ANSI C preprocessor;
                              issues warnings for function calls not in the
                              scope of a function prototype; does not allow
                              Domain extensions; does not define the
                              preprocessor symbol lint.

               nansi          Non-ANSI mode.  Uses the K&R C preprocessor;
                              does not issue warnings for function calls not
                              in the scope of a function prototype; allows
                              Domain extensions; defines the preprocessor
                              symbol lint.

     The -D, -U, and -I options of cpp(1) and the -g and -O options of cc(1)
     are also recognized as separate arguments.  The -g and -O options are
     ignored, but, by recognizing these options, lint's behavior is closer to
     that of the cc(1) command.  Other options are warned about and ignored.
     The pre-processor symbols __lint and __LINT__ are defined to allow
     certain questionable code to be altered or removed for lint.  In
     addition, the pre-processor symbol lint is defined when -A nansi is
     specified.

     Certain conventional comments in the C source change the behavior of
     lint:

          /*NOTREACHED*/
                    At appropriate points 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.
                    This is equivalent to using the -v and -x options.

     lint produces its first output on a per-source-file basis.  Complaints
     regarding included files are collected and printed after all source files
     have been processed.  Finally, if the -c option is not used, information
     gathered from all input files is collected and checked for consistency.
     At this point, if it is not clear whether a complaint stems from a given
     source file or from one of its included files, the source file name is
     printed followed by a question mark.

     The behavior of the -c 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 -c option.  Each of these invocations produces
     a .ln file which 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 -c
     option), listing all the .ln files with the needed -lx options.  This
     prints all the inter-file inconsistencies.  This scheme works well with
     make(1); it allows make to lint only the source files that have been
     modified since the last time the set of source files were linted.

EXTERNAL INFLUENCES
   Environment Variables
     When set, the TMPDIR environment variable specifies a directory to be
     used for temporary files, overriding the default directories /tmp and
     /usr/tmp.

     Long error messages are split across lines to make them easier to read.
     The environment variable COLUMNS controls the maximum number of
     characters on each line.

BUGS
     exit(2), setjmp(3C), and other functions that do not return are not
     understood; this causes various lies.

FILES
     /usr/lib/lint[12]
          First and second passes
     /usr/bin/lint
          Shell script that invokes lint[12]
     /usr/lib/llib-lc.ln
          Declarations for C Library functions (binary format; source is in
          /usr/lib/llib-lc)
     /usr/lib/llib-port.ln
          Declarations for portable functions (binary format; source is in
          /usr/lib/llib-port)
     /usr/lib/llib-lm.ln
          Declarations for Math Library functions (binary format; source is in
          /usr/lib/llib-lm)
     /usr/tmp/*lint*
          Temporaries

SEE ALSO
     cc(1), cpp(1), make(1).

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026