📄 lint.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>lint</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_1137"> </a>NAME</h4><blockquote>lint - check C-language programs (<b><a href="intro.html#tag_001_003_001">DEVELOPMENT</a></b>, <b><a href="intro.html#tag_001_003_003">LEGACY</a></b>)</blockquote><h4><a name = "tag_001_014_1138"> </a>SYNOPSIS</h4><blockquote><pre><code>lint <b>[</b>-abcnpuxv<b>] [</b>-D <i>name</i>=<i>value</i><b>]][</b>-I <i>directory</i><b>][</b>-L <i>directory</i><b>][</b>-o <i>x</i><b>][</b>-U <i>name</i><b>] </b><i>operand</i>... </code></pre></blockquote><h4><a name = "tag_001_014_1139"> </a>DESCRIPTION</h4><blockquote>The<i>lint</i>utility cross-checks multiple C-language source files and librarydefinitions and reports potential errors.Among the error conditions that are detected are:<ul><p><li>unreachable statements<p><li>loops not entered at the top<p><li>automatic variables declared and not used<p><li>inconsistent declarations between files<p><li>non-portable constructions<p><li>logical expressions whose value is constant<p><li>functions that return values in some places and not in others<p><li>functions called with varying numbers or types of arguments<p><li>functions whose values are not used or whose values are usedwhen none are returned.<p></ul><p>The<i>lint</i>utility takes all the files with.cand.lnsuffixes, andany additional lint libraries specified by the<b>-l</b>operand,and processes them in their command-line order.By default,<i>lint</i>appends the standard C lint libraryto the end of the list of files.However, if the<b>-p</b>option is used, the portable C lint library<b>(llib-port.ln)</b>if it exists,will be appended instead.When the<b>-c</b>option is not used,<i>lint</i>checks this list of files for mutual compatibility.When the<b>-c</b>option is used, the.lnfiles and the lint libraries are ignored.<p>Certain conventional comments in the C sourcechange the behaviour of<i>lint</i>:<dl compact><dt>/*NOTREACHED*/<dd>Stop comments about unreachable code at appropriate points.<dt>/*VARARGS<i>n</i>*/<dd>Suppressthe usual checking for variable numbers of argumentsin the following function declaration.The data types of the first<i>n</i>arguments are checked;a missing<i>n</i>is taken to be zero.<dt>/*ARGSUSED*/<dd>Suppress diagnostic messages about unused arguments in the next function.<dt>/*LINTLIBRARY*/<dd>Suppress, at the beginning of a file,diagnostic messages about unused functionsand function arguments in this file.This is equivalent to using the<b>-v</b>and<b>-x</b>options.</dl><p>Other comments in the C source of the form:<pre><code>/\*[[:upper:]][[:upper:][:digit:]]*\*/</code></pre>(where the form is expressed using the syntax of basic regular expressions,defined inthe <b>XBD</b> specification, <a href="../xbd/re.html#tag_007_003"><b>Basic Regular Expressions</b> </a> )may be interpreted by<i>lint</i>in implementation-dependent ways.<p>If the<b>-c</b>option is specified, then for all pathname operands of the form<i>file</i>.cthe files:<pre><code>$(basename <i>pathname</i> .c).ln</code></pre>are produced.<p>If the<b>-o</b>option is present with option-argument<i>x</i>,a file with the name:<pre><code>llib-l$(basename <i>x</i>).ln</code></pre>is produced.<p>The<i>lint</i>utility produces its first output on a per-source-file basis.Diagnostic messagesregarding input files are collected and printedafter all source files have been processed.Finally, if the<b>-c</b>option is not used,information gathered from all input files is collected and checked forconsistency.At this point,if it is not clear whether a diagnostic messagestems from a given source file or fromone of its included files,the source filename will be printed followed by a question mark.<p>During the execution of<i>lint</i>,values are established for certain predefined macros from the ISO C standard:__LINE__,__FILE__,__DATE__,__TIME__and__STDC__.</blockquote><h4><a name = "tag_001_014_1140"> </a>OPTIONS</h4><blockquote>The<i>lint</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> ,except that the<b>-l</b>operands have the format of options, but theirposition within a list of operands affects theorder in which libraries are searched.<p>The following options are supported:<dl compact><dt><b>-a</b><dd>Suppress diagnostic messagesabout assignments of long values to variables that are not long.<dt><b>-b</b><dd>Suppress diagnostic messages about<b>break</b>statements that cannot be reached.<dt><b>-c</b><dd>Produce a<b>.ln</b>file for every<b>.c</b>file on the command line.These<b>.ln</b>files are not checked for interfunction compatibility.<dt><b>-h</b><dd>Do not apply heuristic tests that attempt to diagnose bugs intuitively,improve style and reduce waste.<dt><b>-n</b><dd>Do not check compatibility against either the standard or the portablelint library.<dt><b>-o </b><i>x</i><dd>Produce a lint library with the name:<pre><code>llib-l$(basename <i>x</i>).ln.</code></pre>The<b>-c</b>option nullifies any use of the<b>-o</b>option.The<b>-o</b>option causes this file to be saved in the named lint library.To produce the lint librarywithout extraneous messages, the<b>-x</b>option should be used.The<b>-v</b>option is useful if the source files for the lint libraryare just external interfaces.These option settings are also available through theuse of the "lint comments" listed in the DESCRIPTION section.<dt><b>-p</b><dd>Cause all non-external names to be treated as if they weretruncated to thirty-one characters and all externalnames 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.<dt><b>-u</b><dd>Suppress diagnostic messagesabout functions and externalvariables used and not defined, or defined and not used.(This option is suitable for running<i>lint</i>on a subset of files of a larger program.)<dt><b>-v</b><dd>Suppress diagnostic messagesabout unused arguments in functions.<dt><b>-x</b><dd>Do not report variables referred to by external declarations but never used.</dl><p>The<b>-D</b>,<b>-U</b>,<b>-L</b>and<b>-I</b>options of the C compiler(see<i><a href="cc.html">cc</a></i>and<i><a href="c89.html">c89</a></i>)are also recognised as separate arguments.<p>The<b>-g</b>and<b>-O</b>options of the C compilerare also recognised as separate arguments,but are ignored.(By recognising these options, the behaviour of<i>lint</i>is closer to that of the<i><a href="cc.html">cc</a></i>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 questionablecode to be altered or removed for<i>lint</i>.</blockquote><h4><a name = "tag_001_014_1141"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>file</i><b>.c</b><dd>A pathname naming a C-language source file.<dt><i>file</i><b>.ln</b><dd>A pathname of a file analogous to a<b>.o</b>file produced by the C compiler.</dl><p>An operand of the form<b>-l</b> <i>x</i>means search the library named
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -