|
|
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 library, llib-lc.ln, is 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.
$ lint -lx file1.c file2.cdirects 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
directive / 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:
$ lint -ox files headed by /causes only definitions in the source files headed by /LINTLIBRARY
/
$ lint -y -ox file1.c file2.ccauses each source file named on the command line to be treated as if it began with /
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:
$ lint -Ldir -lx file1.c file2.cThe specified directory is searched before the standard place.