You can use lint libraries to check your program for compatibility with the library functions you have called in it: the declaration of the function return type, the number and types of arguments the function expects, and so on. The standard lint libraries correspond to libraries supplied by the C compilation system, and generally are stored in the standard place on your system, the directory /usr/ccs/lib. By convention, lint libraries have names of the form llib-lx.ln.
The lint standard C libraries, llib-lgen and llib-crypt, are appended to the lint command line by default; checks for compatibility with it can be suppressed by invoking the -n option. Other lint libraries are accessed as arguments to -l.
$directs lint to check the usage of functions and variables in file1.c and file2.c for compatibility with the lint library llib-lx.ln. The library file, which consists only of definitions, is processed exactly as are ordinary source files and ordinary .ln files, except that functions and variables used inconsistently in the library file, or defined in the library file but not used in the source files, elicit no complaints.
To create your own lint library, insert the
/ LINTLIBRARY / at the head
of a C source file, then invoke lint for
that file with the -o option and the library name
that will be given to -l:
$causes only definitions in the source files headed by
lint -ox files headed by / LINTLIBRARY /
/ LINTLIBRARY /to be written to the file llib-lx.ln. (Note the analogy of lint -o to cc -o.) A library can be created from a file of function prototype declarations in the same way, except that both
/ LINTLIBRARY /and
/must be inserted at the head of the declarations file. If n is 1, prototype declarations will be written to a library .ln file just as are old-style definitions. If n is 0, the default, the process is cancelled. Invoking lint with -y is another way of creating a lint library:
$causes each source file named on the command line to be treated as if it began with
lint -y -ox
/ LINTLIBRARY /and only its definitions to be written to llib-lx.ln.
By default, lint searches for lint libraries in the standard place. To direct lint to search for a lint library in a directory other than the standard place, specify the path of the directory with the -L option:
$The specified directory is searched before the standard place.