*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> lint (1)              
Title
Content
Arch
Section
 

lint(1)

Contents


NAME    [Toc]    [Back]

       lint - a C program checker

SYNOPSIS    [Toc]    [Back]

       lint  [-abchlnpuvx]  [-Xdollar]  [-wclass...] [-cpp] [-lx]
       [-olib]  [-dpath]   [-MA]   [-Msuboptions]   [-Pppoptions]
       [-stdn] [-XEnum] [-Qsuboptions] [-Ndnum] [-Nlnum] [-Nnnum]
       [-Ntnum]  [-Dname[=definition]]   [-Idirectory]   [-Uname]
       file...

OPTIONS    [Toc]    [Back]

       Any  number  of  lint  options  may be used, in any order,
       intermixed with file-name arguments. The following options
       are used to suppress certain kinds of complaints: Suppress
       complaints about assignments of long values  to  variables
       that are not long.  Suppress complaints about break statements
 that cannot be reached. (Programs produced by lex or
       yacc  will  often result in many such complaints).  Do not
       apply heuristic tests that attempt to intuit bugs, improve
       style,  and reduce waste.  Suppress 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).   Suppress
       complaints  about  unused  arguments in functions.  Do not
       report variables referred to by external declarations  but
       never used.  Suppress complaints about the use of the dollar
 sign ($) in variable names.  Controls the reporting of
       warning   classes.  All  warning  classes  are  active  by
       default. They can however, be  individually  activated  by
       including  the  appropriate  option  as  part of the class
       argument. For example, to report only declaration  consistency
  and  Heuristic complaints, enter the following command:
 lint -wA -wdh prog.c

              In the preceding example, -wA deactivates all warnings
  and  -wdh  activates the desired reports. The
              following list describes available classes of warnings:
  Non-ANSI  features Comparisons with unsigned
              values Declaration consistency Heuristic complaints
              Suppresses  the following messages: function prototype
 not in scope and old style  argument  declaration.
   Assignment of long values to variables that
              are not long  Null-effect  code  Unknown  order  of
              evaluation   Various  portability  concerns  Return
              statement consistency Proper usage of variables and
              functions Deactivates all warnings Constants occurring
 in conditionals Declarations  that  are  never
              used or defined.  Obsolete features Function prototype
 presence Detection of unreachable code Storage
              capacity checks Equivalent to -u

       The following options alter lint's behavior: Cause lint to
       use /lib/cpp as its preprocessor instead  of  /usr/bin/cc.
       Include  additional  lint library llib-lx.ln. For example,
       you can include a lint version of the Math  Library  lliblm.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. To
       conform to the UNIX98 standard, a space character  can  be
       inserted between the -l and the library identifier, x (for
       example you can specify -l m to include a lint version  of
       the  Math  Library).   Do  not check compatibility against
       either the standard or the portable lint library.  Do  not
       check  compatibility  between files or the lint libraries.
       Attempt 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.  Cause lint to produce a file for
       every  file on the command line. These files are the product
 of lint's first pass only, and  are  not  checked  for
       inter-function compatibility.  Cause 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 that is 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 of the -x option is suggested. 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).
       Cause lint to store the files created as a result  of  the
       -o  or  -c  option  in the specified path.  Enforce ANSI C
       standard rules.  The default lint preprocessing and  parsing
 mode is Extended C (K&R).  ANSI mode prepends (adds at
       the beginning) the standard ANSI library  function  prototypes
  in  place  of  the default extended-mode C library.
       ANSI mode enforces  a  stricter  interfile  object  reference/definition
 linkage checking. This option also invokes
       the -std1 C preprocessor  option  and  defines  the  macro
       _ANSI_C_SOURCE.   Turn  on  or off specific ANSI features.
       The following suboptions are supported: follow ANSI  parsing
 rules follow ANSI const array struct member bug follow
       ANSI type compatibility rules follow ANSI  type  promotion
       rules follow ANSI strict reference/definition rules follow
       ANSI scoping rules for externs follow ANSI typing rules

              The following rules govern the effects  of  the  -M
              option: If A is specified in a single instance of a
              -M option (-MA), the checking for all of the suboptions
  is  turned on.  If any of the suboptions are
              specified in a single instance of a -M option  when
              A  is  also specified (-MAsuboptions), the checking
              for the specified suboptions is turned off.  If any
              of  the  suboptions  are  specified  twice  in  all
              instances of the -M option, they cancel each  other
              out.   If  suboptions  are  specified  in  a single
              instance of a -M option  and  A  is  not  specified
              (-Msuboptions), the checking for only the specified
              suboptions is turned on.

              For example, -MAt turns on all  ANSI  rules  except
              ANSI  typing  rules.  Allows C preprocessor options
              to be specified when executing  the  lint  command.
              For  example, specifying -PV invokes the preprocessor
 with the -V option specified.   Directs  the  C
              Preprocessor to generate the appropriate predefined
              macros. The -std option causes the macro __STDC__=0
              to  be passed to the preprocessor; -std1 causes the
              macro __STDC__=1 to be  passed,  and  -std0  causes
              __STDC__ to be undefined. The default is -std0. The
              -std0 option is incompatible with the -M option. If
              -std  or  -std1  are selected, the -MA ANSI parsing
              rules are automatically  selected.   Specifies  the
              number  (num)  of errors lint accepts before terminating.
 By default, lint terminates  after  encountering
 30 errors.

       The -Q option turns on checking for all common programming
       techniques which might cause  problems  when  moving  from
       32-bit  systems  to 64-bit systems. The -Q option disables
       checking for other programming problems,  so  this  switch
       should be used only for migration checking.

       Suboptions to -Q have the form -Qsuboptions. You can enter
       more than one suboption with the -Q option,  for  example,
       -QacP to suppress checking for pointer alignment problems,
       problematic type casts,  and  function  prototype  checks,
       respectively.

       The  following  suboptions  are available to suppress specific
  categories  of  checking:  Suppresses  checking  of
       pointer alignment problems.  Suppresses checking for problematic
 type casts. (Overrides  -QG  option.)   Suppresses
       checking  for  format control strings in scanf and printf.
       Suppresses checking for  assignments  of  long  values  to
       variables  of a type other than long.  Suppresses checking
       for illegal combinations pointer and integer  data  types.
       Suppresses  checking  for  problematic  sign extensions to
       long Suppresses checking to see  if  a  variable  is  used
       before  it is set.  Suppresses checking to see if there is
       constant truncation of longs in an assignment.  Suppresses
       checking  to  see  if  precision  has  been  lost in field
       assignment.  Suppresses truncation message when casting to
       char  *.  (Overridden by -Qc option.)  Suppresses function
       prototype checks.  Suppresses checking for  a  problematic
       combination  of  structure pointers. If structure checking
       and cast checking are not suppressed then the  casting  of
       differing   structures  and  pointers  to  structures  are
       flagged if the structures differ in size and/or  alignment
       as  described in the following two suboptions.  Suppresses
       warnings about casting a structure or structure pointer to
       one  of a different size. Takes effect only if c and S are
       not specified on the command  line.   Suppresses  warnings
       about  casting a structure or structure pointer to on of a
       different alignment. Takes effect only if c and S are  not
       specified on the command line.

       The  -N  option  and  its  related suboptions allow you to
       increase the size of various internal tables at  run  time
       if  the  default  values  are  not  sufficient. All of the
       tables are dynamically expandable; however, larger initial
       values may improve run-time performance.

       Suboptions  to the -N option take the form -Nzx where z is
       a suboption and x is an integer size. The following suboptions
  are  available: Use with -N to increase the initial
       size of the  symbol  table.  To  increase  the  number  of
       entries, use -Nnnum to increase the number of entries. Use
       a number greater than 1500, which is  the  default  value.
       The larger the number, the fewer collisions.  As a rule of
       thumb, use a number roughly twice  the  number  of  source
       code lines.  Use with -N when you encounter the error that
       the dimension table has overflowed or is full. To increase
       the  number  of  base elements allocated to the members of
       the dimension tables, use  a  number  greater  than  2000,
       which  is  the  default  value.   Use  with  -N  when  you
       encounter the error stating that the parse tree limit  has
       been  reached,  "out  of  tree  space; recompile with -Ntx
       option with x greater than xxxx". Do  not  recompile;  run
       lint  again  on  the module that generated the error using
       -Ntyyyy with yyyy greater than the value in the error message.
   Use  with  -N when you encounter the error stating
       that the local type table limit has been reached, "out  of
       tree space; recompile with -Nlx option with x greater than
       xxxx". Run lint again, do not  recompile,  on  the  module
       that  generated the error, using -Nlyyyy with yyyy greater
       than the value in the error message.

       The -D, -I, and -U options  of  cpp  and  the  -g  and  -O
       options  of  cc 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
       command. Other options are warned about and  ignored.  The
       preprocessor  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.

       The  following  lint  directives,  which appear as conventional
 comments in the C source program, change the behavior
  of  lint:  Prevents  lint from warning against unused
       function arguments (that is, turns on the -v  option)  for
       the  next  function.   When  placed  at the beginning of a
       file, suppresses complaints  about  unused  functions  and
       function  arguments  in  this  file. This is equivalent to
       using the -v and -x options. This directive  is  used  for
       building  lint  libraries.   Permits  a standard prototype
       checking library to be formed from header files by  making
       function prototype declarations appear as function definitions.
 The /*LINTSTDLIB*/ directive  implicitly  activates
       the  functions  of  the  /*NOTUSED*/  and  /*LINTLIBRARY*/
       directives to reduce warning noise levels.  When placed in
       a  file,  suppresses warnings about all used but undefined
       external  symbols  and  functions  that  are  subsequently
       encountered  in  the  file.   When  placed  at appropriate
       points in a program  (typically  immediately  following  a
       return,  break,  or  continue  statement),  stops comments
       about unreachable code. Note that lint does not  recognize
       the exit function and other functions that may not return.
       When placed in  a  file,  suppresses  warnings  about  all
       unused  external  symbols, functions, and function parameters
 that are subsequently encountered in the  file.  This
       directive  is  similar  to  the /*LINTLIBRARY*/ directive,
       although /*NOTUSED*/ also  applies  to  external  symbols.
       Suppresses  the  usual  checking  for  variable numbers of
       arguments in the following function declaration. The  data
       types  of the first n arguments are checked; for instance,
       if /*VARARGS2*/ is specified, lint checks only  the  first
       two arguments. If n is not specified, it is interpreted as
       a 0 (zero).

       The lint utility produces  its  first  output  on  a  persource-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 will be
       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 file which
       corresponds to the 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 files with
       the needed -lx options. This will print all the inter-file
       inconsistencies.   This scheme works well with make(1); 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.

DESCRIPTION    [Toc]    [Back]

       The lint program checker 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 are taken to  be  C  source
       files.  Arguments whose names end with are taken to be the
       result of an earlier invocation of lint with either the -c
       or  the  -o  option  used.   The  files  are  analogous to
       (object) files that are produced by the  cc  command  when
       given  a  file as input. Files with other suffixes produce
       warnings and are ignored.

       The lint program checker  will  take  all  the  llib-lx.ln
       (specified by -lx) files and process them in their command
       line order. It appends a lint library file to this list of
       files,  as follows: If the -p option is used, the portable
       C lint library (llib-port.ln) is appended.  If the -std or
       -std1  option  is  used, the C standard lint library lliblcstd.ln)
 is appended.  If the -MA  option  is  used,  the
       ANSI  standard  lint  library (llib-lansi.ln) is appended.
       Otherwise, the standard C  lint  library  (llib-lc.ln)  is
       appended.

       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 and the llib-lx.ln files are
       ignored.

RESTRICTIONS    [Toc]    [Back]

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

FILES    [Toc]    [Back]

       The  directory  where  the lint libraries specified by the
       -lx option must  exist.   The  directory  where  the  lint
       library  sources  are  kept.   First  and second passes of
       lint.  Declarations for C library functions  (binary  format;
  source  is  in  llib-lc.c).  Declarations for Curses
       library   functions   (binary   format;   source   is   in
       llib-lcrses.c).   Declarations  for  C  library  functions
       (binary format; source  is  in  llib-lc.c).  This  is  the
       default  library  when  the  -std  or  -std1  command line
       options are used with lint.  Declarations for LEX  library
       functions   (binary   format;  source  is  in  llib-ll.c).
       Declarations for Math library  functions  (binary  format;
       source  is  in  llib-lm.c).  Declarations for YACC library
       functions (binary format; source is in llib-ly.c).  Declarations
  for  the  POSIX  thread library functions (binary
       format; source is in llib-lpthread.c).   Declarations  for
       the  POSIX  real-time extensions library functions (binary
       format;  source  is  in  llib-lrt.c).   Declarations   for
       portable  functions  (binary  format;  source  is in llibport.c).
  Temporary files (default directory /usr/tmp).

SEE ALSO    [Toc]    [Back]

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



                                                          lint(1)
[ Back ]
 Similar pages
Name OS Title
tack Linux terminfo action checker
tcpdchk OpenBSD tcp wrapper configuration checker
tcpdchk FreeBSD tcp wrapper configuration checker
tcpdchk Linux tcp wrapper configuration checker
pwck IRIX password file checker
chkconfig IRIX configuration state checker
grpck IRIX group file checker
quotacheck IRIX EFS filesystem quota consistency checker
quotacheck OpenBSD filesystem quota consistency checker
fsck_msdos OpenBSD DOS/Windows (FAT) filesystem consistency checker
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service