Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lint(1) — A/UX 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

cpp(1)

make(1)




lint(1) lint(1)
NAME lint - invokes a C program checker SYNOPSIS lint [-a] [-b] [-Dname[=def]] [-h] [-Idir] [-lx] [-n] [-o lib] [-p] [-u] [-Uname] [-v] [-x] file... ARGUMENTS -a Suppresses complaints about assignments of long values to variables that are not long. -b Suppresses complaints about break statements that cannot be reached. (Programs produced by lex or yacc will often result in many such complaints.) -Dname[=def] Defines name as if by a #define directive. If no =def if given, name is defined as 1. file Specifies the file to be checked. -h Does not apply heuristic tests that attempt to intuit bugs, improve style, and reduce waste. -Idir Searches for #include files (whose names do not begin with /) in dir before looking in the directories on the standard list. When this option is used, #include files whose names are enclosed in double quotes are searched for first in the directory of the ifile argument, then in directories named in -I options, and last in directories on a standard list, which, at present, consists of /usr/include. If the -Y option (see below) is specified, the standard list is not searched. For #include files whose names are enclosed in <>, the directory of the ifile argument is not searched, unless -I. is specified. -lx Includes an 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 multifile projects. To generate llib-lX.ln from llib-lX, use cc -E -C -Dlint llib-lX | \ /usr/lib/lint1 -vx -H/tmp/lint$$ > llib-1X.1n rm -f /tmp/lint$$ January 1992 1



lint(1) lint(1)
-n Does not check compatibility against either the standard or the portable lint library. -o lib Causes lint to create a new lint library that has the name llib-llib.ln. The lint library produced is the input that is given to the second pass of lint. This 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 (as shown later in this section). -p Attempts to check portability to other dialects (IBM and GCOS) of C. Along with stricter checking, this option causes all nonexternal names to be truncated to eight characters and all external names to be truncated to six characters and one case. -u Suppresses 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.) -Uname Removes any initial definition of name, where name is a reserved symbol that is predefined by the particular preprocessor. The list of reserved symbols is shown below: operating system: unix hardware: m68k UNIX System varient: _SYSV_SOURCE _BSD_SOURCE _AUX_SOURCE -v Suppresses complaints about unused arguments in functions. -x Does not report variables referred to by external declarations but never used. 2 January 1992



lint(1) lint(1)
DESCRIPTION lint 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. Features currently detected include unreachable statements, loops not entered at the top, automatic variables declared and not used, and logical expressions whose value is constant. Moreover, function usage is checked to find functions that return values in some places and not in others, functions that are called with varying numbers or types of arguments, and functions whose values are not used or whose values are used but not returned. Arguments whose names end with .c are taken to be C source files. Arguments whose names end with .ln are taken to be the result of an earlier invocation of lint with the -o option used. The .ln files are analogous to .o (object) files that are produced by the cc command when given a .c file as input. Files with other suffixes are warned about and ignored. The lint command will take all the .c, .ln, and llib-lx.ln (specified by -lx) files and process them in 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. The second pass of lint checks this list of files for mutual compatibility. Any number of lint options may be used, in any order, intermixed with filename arguments. The -a, -b, -h, -u, -v, and -x options are used to suppress certain kinds of complaints. The -g and -O options are ignored, but, by recognizing them, the behavior of lint 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*/ Stops comments about unreachable code at appropriate points. (This comment is typically placed just after calls to functions like exit(2).) January 1992 3



lint(1) lint(1)
/*VARARGSn*/ Suppresses the usual checking for variable numbers of arguments in the function declaration that follows it. The data types of the first n arguments are checked; a missing n is assumed to be 0. /*ARGSUSED*/ Turns on the -v option for the next function. /*LINTLIBRARY*/ Shuts off (at the beginning of a file) complaints about unused functions and function arguments in this file. This is equivalent to using the -v and -x options. lint produces its first output on a per-source-file basis. Complaints pertaining to included files are collected and printed after all source files have been processed. Finally, 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 filename will be printed followed by a question mark. EXAMPLES The command: lint -b myfile.c checks the consistency of the file myfile.c. The -b option indicates that unreachable break statements are not to be checked. This option might well be used on files that lex generates. LIMITATIONS exit(2), longjmp(3C), and other functions that do not return are not understood; this causes various lies. FILES /usr/bin/lint Executable file /usr/lib Directory where the lint libraries specified by the -lx option must exist /usr/lib/lint[12] File containing first and second passes /usr/lib/llib-lc.ln Declarations for C Library functions (binary format) /usr/lib/llib-port.ln File containing declarations for portable functions (binary format) /usr/lib/llib-lm.l File containing declarations for Math Library functions 4 January 1992



lint(1) lint(1)
(binary format) /usr/tmp/*lint* Temporary files SEE ALSO cc(1), cpp(1), make(1) ``lint Reference,'' in A/UX Programming Languages and Tools, Volume 1 January 1992 5

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026