The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


lint - check C-language programs (DEVELOPMENT, LEGACY)


lint [-abcnpuxv] [-D name=value]][-I directory][-L directory]
[-o x][-U name] operand... 


The lint utility cross-checks multiple C-language source files and library definitions and reports potential errors. Among the error conditions that are detected are:

The lint utility takes all the files with .c and .ln suffixes, and any additional lint libraries specified by the -l operand, and processes them in their command-line order. By default, lint appends the standard C lint library to the end of the list of files. However, if the -p option is used, the portable C lint library (llib-port.ln) if it exists, will be appended instead. When the -c option is not used, lint checks this list of files for mutual compatibility. When the -c option is used, the .ln files and the lint libraries are ignored.

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

Stop comments about unreachable code at appropriate points.
Suppress 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 zero.
Suppress diagnostic messages about unused arguments in the next function.
Suppress, at the beginning of a file, diagnostic messages about unused functions and function arguments in this file. This is equivalent to using the -v and -x options.

Other comments in the C source of the form:


(where the form is expressed using the syntax of basic regular expressions, defined in the XBD specification, Basic Regular Expressions  ) may be interpreted by lint in implementation-dependent ways.

If the -c option is specified, then for all pathname operands of the form file.c the files:

$(basename pathname .c).ln

are produced.

If the -o option is present with option-argument x, a file with the name:

llib-l$(basename x).ln

is produced.

The lint utility produces its first output on a per-source-file basis. Diagnostic messages regarding input 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 diagnostic message stems from a given source file or from one of its included files, the source filename will be printed followed by a question mark.

During the execution of lint, values are established for certain predefined macros from the ISO C standard: __LINE__, __FILE__, __DATE__, __TIME__ and __STDC__.


The lint utility supports the XBD specification, Utility Syntax Guidelines  , except that the -l operands have the format of options, but their position within a list of operands affects the order in which libraries are searched.

The following options are supported:

Suppress diagnostic messages about assignments of long values to variables that are not long.
Suppress diagnostic messages about break statements that cannot be reached.
Produce a .ln file for every .c file on the command line. These .ln files are not checked for interfunction compatibility.
Do not apply heuristic tests that attempt to diagnose bugs intuitively, improve style and reduce waste.
Do not check compatibility against either the standard or the portable lint library.
-o x
Produce a lint library with the name:

llib-l$(basename x).ln.

The -c option nullifies any use of the -o option. The -o option causes this file to be saved in the named lint library. To produce the lint library without extraneous messages, the -x option should be used. The -v option is useful if the source files for the lint library are just external interfaces. These option settings are also available through the use of the "lint comments" listed in the DESCRIPTION section.
Cause all non-external names to be treated as if they were truncated to thirty-one characters and all external names truncated to six characters, folded to one case. Append the portable C lint library, if it exists, to the end of the list of files.
Suppress diagnostic messages 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 diagnostic messages about unused arguments in functions.
Do not report variables referred to by external declarations but never used.

The -D, -U, -L and -I options of the C compiler (see cc and c89) are also recognised as separate arguments.

The -g and -O options of the C compiler are also recognised as separate arguments, but are ignored. (By recognising these options, the behaviour of lint is closer to that of the cc utility.) Other options are ignored, and a warning message may be issued. The pre-defined macro lint (for common-usage C) or __LINT__ (for the ISO C standard) is defined to allow certain questionable code to be altered or removed for lint.


The following operands are supported:
A pathname naming a C-language source file.
A pathname of a file analogous to a .o file produced by the C compiler.

An operand of the form -l x means search the library named llib-lx.ln or llib-lx if llib-lx.ln is not readable.

The processing of other files is implementation-dependent.

The lint utility will recognise the following -l operands for standard libraries:

-l c
Names the Standard C library, llib-lc.ln, which will contain everything else defined by the ISO C standard. The library searched also will include all functions defined by the XSH specification. This operand is not required to be present to cause a search of the Standard C library.
-l l
Names the library llib-ll.ln, which will contain functions required by the C-language output of lex that are not available through the Standard C library.
-l m
Names the library llib-lm.ln, which contains the functions described by the ISO C standard with prototypes in the <math.h> header.
-l pthread
Names the library llib-lpthread.ln, which contains the functions declared in <pthread.h> and pthread_atfork() referenced in <unistd.h>.
-l rt
Names the library llib-lrt.ln, which contains the functions described by the Realtime Feature Group.
-l y
Names the library llib-ly.ln, which contains functions required by the C-language output of yacc that are not available through the Standard C library.

It is unspecified whether the libraries llib-lc.ln, llib-ll.ln, llib-lm.ln, llib-lpthread.ln, llib-lrt.ln, or llib-ly.ln (or any other library accessed via -l) exist as regular files.


Not used.


The input file must be one of the following: a .c suffixed text file containing C-language source or a .ln suffixed file of unspecified format produced by a previous invocation of lint with a -c or -o option.


The following environment variables may affect the execution of lint:
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
Determine the location of message catalogues for the processing of LC_MESSAGES .




The format of the report produced by lint is unspecified.


Used only for diagnostic and warning messages.


The format of .ln files is unspecified.


The lint utility supports the same programming environments specified in , EXTENDED DESCRIPTION. The default programming environment supported by lint will be the same as the default programming environment supported by c89. To use lint to cross-check C-language source files and library definitions for other supported programming environments, provide the corresponding lint flags as the first options on the lint command line.
Programming Environment
getconf Name
Corresponding lint Arguments
getconf Name
Table: Programming Environments - lint Flags


The following exit values are returned:
Successful completion.
An error occurred.




The behaviour of the -c and the -o options allows for incremental use of lint on a set of C source files. Generally, lint is invoked once for each source file with the -c option. Each of these invocations produces a .ln file that corresponds to the .c file, and prints all messages that pertain to 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 -l x options. This will print all the interfile 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 checked by lint. If used incrementally on a set of files, the result of partial checks can be saved to speed subsequent intermodule consistency checks.

The lint library often contains all routines in that library stripped of everything but prototypes.

The intent of allowing unrecognised suffixes is to permit implementations to recognise things like archives and source of other languages, but not require all implementations to do so. Portable applications should use only the suffixes described in this specification.

Programs produced by lex or yacc will often result in many diagnostic messages about break statements that cannot be reached. Use of -b is recommended.


Assuming a file hierarchy as shown here:

$ ls -R
$ cd libsrc

The following creates llib-applib.ln for later use:

$ lint -o applib applib*.c
$ cd ../appsrc

The following checks the source for both applications against the previously created library:

$ for app in *.c
> do
>        lint -L ../libsrc $app -l applib
> done

If the application source and libraries in the previous example had all been built in the _XBS5_LP64_OFF64 programming model, the for loop in the last example would be changed to:

$ for app in *.c
> do
> lint $LFLAGS -L ../libsrc $app -l applib
> done




cc, c89, getconf, lex, make, yacc.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]