Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lint(1) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc

lint

PURPOSE

     Checks C programs for potential problems.

SYNOPSIS
     lint [ options ] file ...


DESCRIPTION

     The lint program checks C language source code for coding
     and  syntax errors  and  for  inefficient or  nonportable
     code.  You can use this program to

     o   Identify source code and library incompatibility
     o   Enforce type  checking rules more strictly  than does
         the compiler
     o   Identify potential problems with variables
     o   Identify potential problems with functions
     o   Identify problems with flow control
     o   Identify legal constructions  that may produce errors
         or be inefficient
     o   Identify possibly nonportable code.

     The lint command assumes that file names ending in .c are
     C Language source files.  It assumes that those ending in
     .ln are  the result  of an earlier  running of  lint with
     either the -c  or the -o flag used.  These  .ln files are
     analogous to  the .o  (object) files  produced by  the cc
     command when  given a .c  file as input.  lint  warns you
     about files with other suffixes and ignores them.

     The lint command  takes all the .c and .ln  files and the
     libraries specified by -l flags and processes them in the
     order that they appear on  the command line.  By default,
     it adds the standard lint library (llib-lc.ln) to the end
     of the  list of files.   However, when you select  the -p
     flag, lint  uses the  portable library  llib-port.ln.  By
     default,  the second  pass of  lint checks  this list  of
     files for  mutual compatibility; however, if  you specify
     the -c flag, lint ignores the .ln and lib-lx files.

     The -c and -o flags allow  for incremental use of lint on
     a set  of C  Language source  files.  Generally,  you use
     lint once for each source file with the -c flag.  Each of
     these runs produces a .ln file that corresponds to the .c
     file and  writes all  messages that  are about  just that
     source file.  After  you have run all  source files sepa-
     rately through lint, you run it once more, without the -c
     flag, listing all the .ln  files with the needed -l argu-
     ments.  This writes all inter-file inconsistencies.  This
     procedure works  well with the make  command, allowing it

     to run  lint on  only those source  files that  have been
     modified since the last time that set of source files was
     checked.

     The following comments  in a C source  program change the
     way that lint operates when checking the source program:

     /*NOTREACHED*/  Suppresses  comments   about  unreachable
                     code.
     /*VARARGSn*/    Suppresses  checking the  following func-
                     tion declaration  for varying  numbers of
                     arguments but does check the data type of
                     the  first n  arguments.  If  you do  not
                     include  a value  for n,  lint checks  no
                     arguments (n=0).
     /*ARGSUSED*/    Turns on  the -v flag for  the next func-
                     tion.
     /*LINTLIBRARY*/ If you  place this comment at  the begin-
                     ning of  a file,  lint does  not identify
                     unused functions in the file.

     The lint command first  writes messages about each source
     file  as it  processes  the file.   It collects  messages
     about included files  and writes those after  it has gone
     through all the  source files.  Finally, if  you have not
     specified the  -c flag, it collects  information gathered
     from all input  files and checks it  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, lint displays  the source file name  followed by a
     question mark.

FLAGS

     -a             Suppresses  messages about  assignments of
                    long  values  to  variables that  are  not
                    long.
     -b             Suppresses   messages  about   unreachable
                    break statements.
     -h             Does  not  try  to  detect  bugs,  improve
                    style, or reduce waste.
     -c             Causes  lint to  produce  a  .ln file  for
                    every .c file on  the command line.  These
                    .ln  files are  the product  of the  first
                    pass of lint only  and are not checked for
                    inter-function compatibility.
     -lkey          Includes   the  additional   lint  library
                    llib-lkey.ln.   You  can  include  a  lint
                    version of the  math library llib-lm.ln by
                    specifying  -lm  on  the command  line  or
                    llib-ldos.ln  by specifying  -ldos on  the
                    command  line.  Use  this flag  to include
                    local lint  libraries when  checking files
                    that are part of  a project having a large
                    number  of  files.   This  flag  does  not
                    prevent  lint  from using  the  llib-lc.ln
                    library.

     -n             Does  not  check  for  compatibility  with
                    either the  standard or the  portable lint
                    libraries.
     -Nnnum         Increases  the size  of the  symbol table.
                    The default size is 1500.
     -o lib         Causes lint to create  a lint library with
                    the name llib-llib.ln.  The -c flag nulli-
                    fies  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 the -x flag.  The -v flag is useful if
                    the source files 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 comment lines.
     -p             Checks  for portability  to  other C  dia-
                    lects.
     -u             Suppresses  messages  about functions  and
                    external  variables that  are either  used
                    and not  defined or defined and  not used.
                    Use this flag  to run lint on  a subset of
                    files of a larger program.
     -v             Suppresses messages about function parame-
                    ters that are not used.
     -x             Suppresses  messages about  variables that
                    have external  declarations but  are never
                    used.

     In addition,  lint recognizes the following  flags of the
     cpp command (macro preprocessor):

     -Dname[=def]   Defines the  name, as if by  #define.  The
                    default def is 1.
     -Idir          Adds  dir to  the list  of directories  in
                    which lint searches for #include files.
     -Uname         Removes  any initial  definition of  name,
                    where name  is a  reserved symbol  that is
                    predefined by the particular preprocessor.

EXAMPLES

     1.  To check a C program for errors:

           lint  program.c

     2.  To suppress some of the messages:

           lint  -v  -x  program.c

         This checks  "program.c", but does not  display error
         messages  about unused  function  parameters (-v)  or
         unused externals (-x).

     3.  To  check  the  program against  an  additional  lint
         library:

           lint  -lsubs  program.c

         This  checks "program.c"  against  both the  standard
         lint      library      (/usr/lib/llib-lc.ln)      and
         /usr/lib/llib-l"subs".ln.
     4.  To check  against the  portable library and  an addi-
         tional library:

           lint -lsubs -p program.c

         This  checks "program.c"  against  both the  portable
         lint     library      (/usr/lib/llib-port.ln)     and
         /usr/lib/llib-l"subs".ln.
     5.  To check against a nonstandard library only:

           lint -lsubs -n program.c

         This     checks      "program.c"     against     only
         /usr/lib/llib-l"subs".ln.

FILES

     /usr/lib/lint[12]        Programs.
     /usr/lib/llib-lc.ln      Declarations for  standard func-
                              tions (binary format).
     /usr/lib/llib-lc         Declarations for  standard func-
                              tions (source).
     /usr/lib/llib-port.ln    Declarations for  portable func-
                              tions (binary format).
     /usr/lib/llib-port       Declarations for  portable func-
                              tions (source).
     /usr/lib/llib-lm.ln      Declarations  for standard  math
                              functions (binary format)
     /usr/lib/llib-lm         Declarations  for standard  math
                              functions (source)
     /usr/lib/llib-ldos.ln    Declarations   for  DOS Services
                              functions (binary format).
     /usr/lib/llib-ldos       Declarations   for  DOS Services
                              functions (source).
     /usr/tmp/*lint*          Temporary files.

RELATED INFORMATION

     The following command:  "cc."

     The topic  "Checking C Programs" in  AIX Operating System
     Programming Tools and Interfaces.

     The "Overview of International Character Support" in Man-
     aging the AIX Operating System.

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