4.5 lint Directives
4.5.1 Predefined Values
Running lint predefines the lint token. See also the cc(1) man page for
a list of predefined tokens.
lint directives in the form of /*...*/ are supported for existing annotations but
will not be supported for future annotations. Directives in the form of source
code annotations, NOTE(...), are recommended for all annotations.
Specify lint directives in the form of source code annotations by including the
file note.h, for example:
lint shares the Source Code Annotations scheme with several other tools. When you
install the Oracle Solaris Studio C compiler, you also automatically install the file
/usr/lib/note/SUNW_SPRO-lint, which contains the names of all the annotations that LockLint understands. However, the
Oracle Solaris Studio C source code checker, lint, also checks all the files
in /usr/lib/note and the Oracle Solaris Studio default location install-directory/prod/lib/note for all valid
You may specify a location other than /usr/lib/note by setting the environment variable
NOTEPATH, as in:
setenv NOTEPATH $NOTEPATH:other_location
The following table lists the lint directives along with their actions.
Table 4-9 lint Directives
n=1, 2, 4, 8, 16, 32, 64, 128
set the following function result alignment in n
bytes. For example,
is defined as returning a char
* or void
* when it actually returns pointers
that are word, or even doubleword, aligned.
Suppresses the following message:
This directive acts
like the -v
option for the next function.
Suppresses the following message for every argument
but the first n in the function definition it precedes. Default is
0. For the NOTE format, n must be specified.
not check the
mentioned arguments for usage (this option acts only for the next function).
following message for every argument listed in NOTE or directive.
Suppresses complaints about
constant operands for the conditional expression. Suppresses the following messages for the constructs
Also NOTE(CONSTANTCONDITION) or /* CONSTANTCONDITION */.
constant in conditional context
constant operands to op: "!"
logical expression always false: op "&&"
logical expression always true: op "||"
Suppresses complaints about a null
statement consequent on
statement. This directive should be placed after the test expression and
before the semicolon. This directive is supplied to support empty if
a valid else
statement follows. It suppresses messages on an empty else
the following messages when inserted between the controlling expression of the if and
statement has no consequent: else
when inserted between the else and semicolon;
statement has no consequent: if
Suppresses complaints about a fall through to a case
statement. This directive should be placed immediately preceding the label.
Suppresses the following message
for the case statement it precedes. Also NOTE(FALLTHROUGH) or /* FALLTHROUGH */.
Suppresses any intra-file warning
except those dealing with unused variables or functions. This directive should be placed
on the line immediately preceding where the lint
warning occurred. The -k
option alters the
way in which lint
handles this directive. Instead of suppressing messages, lint
an additional message, if any, contained in the comments. This directive is useful
in conjunction with the -s
option for post-lint filtering.
When -k is not invoked, suppresses every
warning pertaining to an intra-file problem, except:
argument unused in function
declarations unused in block
set but not used in function
variable not used in function
for the line of code it precedes. msg is ignored.
When -o is invoked, writes to a library
.ln file, only definitions in the .c file it heads. This directive suppresses messages
about unused functions and function arguments in this file.
At appropriate points, stops comments
about unreachable code. This comment is typically placed just after calls to functions
such as exit
Suppresses the following messages for the closing curly brace it
precedes at the end of the function.
statement not reached
for the unreached statements it precedes;
fallthrough on case statement
for the case it precedes that cannot be reached from the preceding case;
function falls off bottom without returning value
Treats the n
th argument of the function
definition it precedes as a [fs]printf()
format string and issues the following messages for
mismatches between the remaining arguments and the conversion specifications. lint
issues these warnings by
default for errors in the calls to [fs]printf()
functions provided by the standard
For the NOTE format, n must be specified.
malformed format strings
for invalid conversion specifications in that argument, and function argument type inconsistent with format
too few arguments for format
too many arguments for format
is 1 and
or /* LINTLIBRARY */
is used, writes to a library .ln
file only the
function prototype declarations in the .c
file it heads. The default is 0,
which cancels the process.
For the NOTE format, n must be specified.
Same as NOTE(PRINTFLIKE(n))
or /* PRINTFLIKEn */
, except that the n
th argument of the function definition is
treated as a [fs]scanf()
format string. By default, lint
issues warnings for errors
in the calls to [fs]scanf()
functions provided by the standard C library.
For the NOTE
format, n must be specified.
Suppresses the usual checking for variable numbers of arguments
in the following function declaration. The data types of the first n
checked; a missing n
is taken to be 0. The use of the
ellipsis (...) terminator in the definition is suggested in new or updated code.
the function whose definition it precedes, suppresses the following message for calls to
the function with n or more arguments. For the NOTE format, n must be