lint(1)								      lint(1)



NAME

  lint - a C program checker

SYNOPSIS

  lint -abchnpuxv] [-Dname[=definition]] [-Idirectory] [-lkey] [-olibrary]
       [-MA] [-Msuboptions] [-stdn] [-Pppoptions] [-Qsuboptions] [-Ndnumber]
       [-Nlnumber] [-Nnnumber] [-Ntnumber] [-Uname] [-wclass...] file...

DESCRIPTION

  The lint program checker attempts to detect features of the 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 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.  Argu-
  ments 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 produce warnings
  and are ignored.

  The lint program checker will take all the .c, .ln , and llib-lx.ln (speci-
  fied by -lx) 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 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 compati-
  bility.  When the -c option is used, the .ln and the llib-lx.ln files are
  ignored.

FLAGS

  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:

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

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

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

  -u  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).

  -v  Suppress complaints about unused arguments in functions.

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

  -wclass
      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 com-
      plaints, 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:

      a	  Non-ANSI features

      c	  Comparisons with unsigned values

      d	  Declaration consistency

      h	  Heuristic complaints

      k	  Supresses the following messages: function prototype not in scope
	  and old style argument declaration.

      l	  Assignment of long values to variables that are not long

      n	  Null-effect code

      o	  Unknown order of evaluation

      p	  Various portability concerns

      r	  Return statement consistency

      u	  Proper usage of variables and functions

      A	  Deactivates all warnings

      C	  Constants occurring in conditionals

      D	  Declarations that are never used or defined.

      O	  Obsolete features

      P	  Function prototype presence

      R	  Detection of unreachable code

      S	  Storage capacity checks

      U	  Equivalent to -u

  The following arguments alter lint's behavior:

  -lx Include 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  Do not check compatibility against either the standard or the portable
      lint library.

  -p  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 trun-
      cated to six characters and one case.

  -c  Cause 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.

  -olib
      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 sug-
      gested.  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).

  -MA Enforces ANSI C standard rules.  The default lint preprocessing and
      parsing mode is Extended C (K&R).	 ANSI preprocessing and parsing rules
      may be selected as an option.  ANSI mode prepends (adds at the begin-
      ning) the standard ANSI library function prototypes in place of the
      default extended mode C library.	ANSI mode enforces a stricter inter-
      file object reference/definition linkage checking. This flag also
      invokes the -std1 C preprocessor option and defines the macro
      _ANSI_C_SOURCE.

  -Msuboption
      The suboptions enforce some of the ANSI parsing rules. These are imple-
      mented as toggles. This flag and set of suboptions can be used to turn
      on or off specific ANSI features.	 For example, -MAt turns on all ANSI
      rules except ANSI typing rules.

	  a   follow ANSI parsing rules

	  b   follow ANSI const array struct member bug

	  c   follow ANSI type compatibility rules

	  p   follow ANSI type promotion rules

	  r   follow ANSI strict ref/def rules

	  s   follow ANSI scoping rules for externs

	  t   follow ANSI typing rules

  -P  Allows C preprocessor options to be specified when executing the lint
      command.	For example, specifying -PV invokes the preprocessor with the
      -V option specified.

  -std[0,1]
      Directs the C Preprocessor to generate the appropriate predefined mac-
      ros.  The -std flag 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.

  The -Q option provides support for migration from ULTRIX and DEC OSF/1 Ver-
  sion 1.0 systems to DEC OSF/1 Version 1.2 and higher versions.  This 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 -Qn. 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:

  a   Suppresses checking of pointer alignment problems.

  b   Suppresses checking for int long mismatches in bit operators.

  c   Suppresses checking for problematic type casts.

  f   Suppresses checking for format control strings in scanf and printf.

  l   Suppresses checking for assignments of long values to variables of a
      type other than long.

  p   Suppresses checking for illegal combinations pointer and integer data
      types.

  s   Suppresses checking for problematic sign extensions to long

  u   Suppresses checking to see if a variable is used before it is set.

  C   Suppresses checking to see if there is constant truncation of longs in
      an assignment.

  F   Suppresses checking to see if precision has been lost in field assign-
      ment.

  G   Suppresses truncation message when casting to char *.

  P   Suppresses function prototype checks.

  S   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.

  Z   Suppresses warnings about casting a structure or structure pointer to
      one of a different size if c and S are not specified on the command
      line.

  g   Suppresses warnings about casting a structure or structure pointer to
      on of a different alignment 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 runtime.  Suboptions to the -N option take the
  form -Nzx where z is a suboption and x is an integer size.

  -N  Use this option with its suboptions to increase the initial size of
      various internal tables at runtime if the default values are not
      sufficient. All of the tables are dynamically expandable; however,
      larger initial values may improve run-time performance.

  nxxxx
      Use with -N to increase the initial size of the symbol table.  To
      increase the number of entries, use -Nnxxxx 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.

  dxxxx
      Use with -N when you encounter the error that the dimension table has
      overflowed or is full. To increase the number of base elements allo-
      cated to the members of the dimension tables, use a number greater than
      2000, which is the default value.

  tx  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". Run lint again, do not recompile, on the
      module that generated the error using -Ntyyyy with yyyy greater than
      the value in the error message.

  lx  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, -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 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(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.

  The lint utility 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 con-
  sistency.  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 .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 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.

RESTRICTIONS

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

FILES

  /usr/ccs/lib
	     The directory where the lint libraries specified by the -lx
	     option must exist.

  /usr/ccs/lib/lint
	     The directory where the lint library sources are kept.

  /usr/ccs/lib/cmplrs/cc/lint[12]
	     first and second passes of lint

  llib-lc.ln declarations for C Library functions (binary format; source is
	     in llib-lc.c)

  llib-port.ln
	     declarations for portable functions (binary format; source is in
	     llib-port.c)

  llib-lm.ln declarations for Math Library functions (binary format; source
	     is in llib-lm.c)

  llib-lcrses.ln
	     declarations for Curses Library functions (binary format; source
	     is in llib-lcrses.c)

  *lint*     temporary files (default directory /usr/tmp)

RELATED INFORMATION

  cc(1), cpp(1), make(1)