Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acc(1)

cc(1)

cpp(1)

make(1)



  lint(1)                             CLIX                             lint(1)



  NAME

    lint - Checks a C program

  SYNOPSIS

    lint [flag] ... file ...

  FLAGS

    The following flags are used to suppress certain kinds of messages:

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

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

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

    -u   Suppresses messages about functions and external variables used and
         not defined, or defined and not used.  (This flag is suitable for
         running lint on a subset of files of a larger program).

    -v   Suppresses messages about unused arguments in functions.

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

    The following flags alter the behavior of lint:

    -ex      Specifies the preprocessor that lint should use.  The valid
             preprocessors are cc, acc, gcc, and cpp.  By default, lint uses
             acc.

    -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 flag does not suppress
             the default use of llib-lc.ln.  These lint libraries must be in
             the assumed directory.  This flag 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 1GCOS)
             of C.  Along with stricter checking, this flag causes all
             nonexternal names to be truncated to eight characters and all



  2/94 - Intergraph Corporation                                              1






  lint(1)                             CLIX                             lint(1)



             external names to be truncated to six characters and one case.

    -c       Causes lint to produce a .ln file for every .c file on the
             command line.  These .ln files are the product of only the first
             pass of lint, 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 flag nullifies any use of the -o flag.  The lint library
             produced is the input that is given to the second pass of lint.
             The -o flag simply causes this file to be saved in the named lint
             library.  To produce a llib-llib.ln without extraneous messages,
             use of the -x flag is suggested.  The v flag 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 flag
             settings are also available through the use of ``lint comments''
             (see the DESCRIPTION section).

    The -D, -U, and -I flags of cpp and the -g and -O flags of cc are also
    recognized as separate arguments.  The -g and -O flags are ignored, but,
    by recognizing these flags, lint behaves much like the cc command.  Other
    flags are warned about and ignored.

  DESCRIPTION

    The lint command attempts to detect features of the C program files that
    are likely to be bugs, nonportable, or wasteful.  It also checks type
    usage more strictly than the compilers.  Among the things that are
    currently detected are unreachable statements, loops not entered at the
    top, automatic variables declared and not used, and logical expressions
    whose value is constant.  Moreover, the usage of functions is checked to
    find 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 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 flag.  The .ln
    files are analogous to .o (object) files that are produced by the cc
    command when given a .c file as input.  Files with other suffixes are
    warned about and ignored.

    The lint command takes all the .c, .ln, and llib-lx.ln (specified by -x)
    files and process 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 flag is used, the portable C lint library
    (llib-port.ln) is appended instead.  When the -c flag is not used, the
    second pass of lint checks this list of files for mutual compatibility.
    When the -c flag is used, the .ln and the llib-lx.ln files are ignored.
    Any number of lint flags may be used, in any order, intermixed with
    filename arguments.



  2                                              Intergraph Corporation - 2/94






  lint(1)                             CLIX                             lint(1)



    The pre-processor symbol lint is defined to allow certain questionable
    code to be altered or removed for lint.  Therefore, 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*/
           At appropriate points, stops comments about unreachable code.
           (This comment is typically placed just after calls to functions
           like exit().

    /*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 flag for the next function.

    /*LINTLIBRARY*/
           At the beginning of a file, shuts off messages about unused
           functions and function arguments in this file.  This is equivalent
           to using the -v and -x flags.

    The lint command produces its first output on a per-source-file basis.
    Messages regarding included files are collected and displayed after all
    source files have been processed.  Finally, if the -c flag 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 message stems
    from a given source file or from one of its included files, the source
    filename will be displayed followed by a question mark.

    The behavior of the -c and the -o flags allows for incremental use of lint
    on a set of C source files.  Invoke lint once for each source file with
    the -c flag.  Each of these invocations produces a .ln file which
    corresponds to the .c file, and displays 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 flag), listing all
    the .ln files with the needed -lx flags.  This displays all the inter-file
    inconsistencies.  This scheme works well with make.  It allows make to be
    used to lint only the source files that have been modified since the last
    time the set of source files were run through lint.

  EXAMPLES

    The following example checks the syntax and semantics of all .c and .h
    files in the current directory:

    lint *.[ch]



  2/94 - Intergraph Corporation                                              3






  lint(1)                             CLIX                             lint(1)



  FILES

    LLIBDIR                The directory where the lint libraries specified by
                           the -lx flag must exist.  This directory is usually
                           /usr/lib.

    LLIBDIR/lint[12]       First and second passes.

    LLIBDIR/llib-lc.ln     Declarations for C Library functions (binary
                           format; source is in LLIBDIR/llib-lc).

    LLIBDIR/llib-port.ln   Declarations for portable functions (binary format;
                           source is in LLIBDIR/llib-port).

    LLIBDIR/llib-lm.ln     Declarations for Math Library functions (binary
                           format; source is in LLIBDIR/llib-lm).

    TMPDIR                 Temporary directory.  Usually /usr/tmp but can be
                           redefined by setting the environment variable
                           TMPDIR (see tempnam() in tmpnam).

    TMPDIR/*lint*          Temporary files.

  CAUTIONS

    The exit(), setjmp(), and other functions that do not return are not
    understood.  This causes various untruths.

  EXIT VALUES

    Exits with 0 if successful.

  RELATED INFORMATION

    Commands:  acc(1), cc(1), cpp(1), make(1)

    AT&T UNIX System V Programmer's Guide

















  4                                              Intergraph Corporation - 2/94




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