JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information

Preface

1.  Introduction to the C Compiler

2.  C-Compiler Implementation-Specific Information

3.  Parallelizing C Code

4.  lint Source Code Checker

4.1 Basic and Enhanced lint Modes

4.2 Using lint

4.3 lint Command-Line Options

4.3.1 -#

4.3.2 -###

4.3.3 -a

4.3.4 -b

4.3.5 -C filename

4.3.6 -c

4.3.7 -dirout=dir

4.3.8 -err=warn

4.3.9 -errchk=l(, l)

4.3.10 -errfmt=f

4.3.11 -errhdr=h

4.3.12 -erroff=tag(, tag)

4.3.13 -errsecurity=level

4.3.14 -errtags=a

4.3.15 -errwarn=t

4.3.16 -F

4.3.17 -fd

4.3.18 -flagsrc=file

4.3.19 -h

4.3.20 -Idir

4.3.21 -k

4.3.22 -Ldir

4.3.23 -lx

4.3.24 -m

4.3.25 -m32|-m64

4.3.26 -Ncheck=c

4.3.27 -Nlevel=n

4.3.27.1 -Nlevel=1

4.3.27.2 -Nlevel=2

4.3.27.3 -Nlevel=3

4.3.27.4 -Nlevel=4

4.3.28 -n

4.3.29 -ox

4.3.30 -p

4.3.31 -Rfile

4.3.32 -s

4.3.33 -u

4.3.34 -V

4.3.35 -v

4.3.36 -Wfile

4.3.37 -XCC=a

4.3.38 -Xalias_level[=l]

4.3.39 -Xarch=amd64

4.3.40 -Xarch=v9

4.3.41 -Xc99[=o]

4.3.42 -Xkeeptmp=a

4.3.43 -Xtemp=dir

4.3.44 -Xtime=a

4.3.45 -Xtransition=a

4.3.46 -Xustr={ascii_utf16_ushort|no}

4.3.47 -x

4.3.48 -y

4.4 lint Messages

4.4.1 Options to Suppress Messages

4.4.2 lint Message Formats

4.5 lint Directives

4.5.1 Predefined Values

4.5.2 Directives

4.6 lint Reference and Examples

4.6.1 Diagnostics Performed by lint

4.6.1.1 Consistency Checks

4.6.1.2 Portability Checks

4.6.1.3 Questionable Constructs

4.6.2 lint Libraries

4.6.3 lint Filters

5.  Type-Based Alias Analysis

6.  Transitioning to ISO C

7.  Converting Applications for a 64-Bit Environment

8.  cscope: Interactively Examining a C Program

A.  Compiler Options Grouped by Functionality

B.  C Compiler Options Reference

C.  Implementation-Defined ISO/IEC C99 Behavior

D.  Features of C99

E.  Implementation-Defined ISO/IEC C90 Behavior

F.  ISO C Data Representations

G.  Performance Tuning

H.  Oracle Solaris Studio C: Differences Between K&R C and ISO C

Index

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.

4.5.2 Directives

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:

#include <note.h>

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 annotations.

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

Directive
Action
NOTE(ALIGNMENT(fname,n)) where n=1, 2, 4, 8, 16, 32, 64, 128
Makes lint set the following function result alignment in n bytes. For example, malloc() is defined as returning a char* or void* when it actually returns pointers that are word, or even doubleword, aligned.

Suppresses the following message:

  • improper alignment

NOTE(ARGSUSED(n))

/*ARGSUSEDn*/

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.

  • argument unused in function

NOTE(ARGUNUSED

(par_name[,par_name...]))

Makes lint not check the mentioned arguments for usage (this option acts only for the next function).

Suppresses the following message for every argument listed in NOTE or directive.

  • argument unused in function

NOTE(CONSTCOND)

/*CONSTCOND*/

Suppresses complaints about constant operands for the conditional expression. Suppresses the following messages for the constructs it precedes.

Also NOTE(CONSTANTCONDITION) or /* CONSTANTCONDITION */.

constant in conditional context

constant operands to op: "!"

logical expression always false: op "&&"

logical expression always true: op "||"

NOTE(EMPTY) /*EMPTY*/
Suppresses complaints about a null statement consequent on an if statement. This directive should be placed after the test expression and before the semicolon. This directive is supplied to support empty if statements when a valid else statement follows. It suppresses messages on an empty else consequent.

Suppresses the following messages when inserted between the controlling expression of the if and semicolon.

  • statement has no consequent: else

    when inserted between the else and semicolon;

  • statement has no consequent: if

NOTE(FALLTHRU)

/*FALLTHRU*/

Suppresses complaints about a fall through to a case or default labelled 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 */.

  • fallthrough on case statement

NOTE(LINTED (msg))

/*LINTED [msg]*/

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 prints 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

  • static unused

  • variable not used in function

    for the line of code it precedes. msg is ignored.

NOTE(LINTLIBRARY)

/*LINTLIBRARY*/

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.
NOTE(NOTREACHED)

/*NOTREACHED*/

At appropriate points, stops comments about unreachable code. This comment is typically placed just after calls to functions such as exit(2).

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

NOTE(PRINTFLIKE(n))

NOTE(PRINTFLIKE(fun_name,n))

/*PRINTFLIKEn*/

Treats the nth 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 C library.

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

NOTE(PROTOLIB(n))

/*PROTOLIBn*/

When n is 1 and NOTE(LINTLIBRARY) 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.

NOTE(SCANFLIKE(n))

NOTE(SCANLIKE(fun_name,n))

/*SCANFLIKEn*/

Same as NOTE(PRINTFLIKE(n)) or /* PRINTFLIKEn */, except that the nth 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.

NOTE(VARARGS(n))

NOTE(VARARGS(fun_name,n))

/*VARARGSn*/

Suppresses the usual checking for variable numbers of arguments in the following function declaration. The data types of the first n arguments are 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.

For 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 specified.

  • functions called with variable number of arguments