JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.2: C User's Guide
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 The lint 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=v

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.  Supported Features of C99

E.  Implementation-Defined ISO/IEC C90 Behavior

F.  ISO C Data Representations

G.  Performance Tuning

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

Index

4.4 lint Messages

Most of lint’s messages are simple, one-line statements printed for each occurrence of the problem they diagnose. Errors detected in included files are reported multiple times by the compiler, but only once by lint, no matter how many times the file is included in other source files. Compound messages are issued for inconsistencies across files and, in a few cases, for problems within them as well. A single message describes every occurrence of the problem in the file or files being checked. When use of a lint filter (see 4.6.2 lint Libraries) requires that a message be printed for each occurrence, compound diagnostics can be converted to the simple type by invoking lint with the -s option.

lint’s messages are written to stderr.

4.4.1 Options to Suppress Messages

You can use several lint options to suppress lint diagnostic messages. Messages can be suppressed with the -erroff option, followed by one or more tags. These mnemonic tags can be displayed with the -errtags=yes option.

The following table lists the options that suppress lint messages.

Table 4-8 lint Options to Suppress Messages

Option
Messages Suppressed
-a
assignment causes implicit narrowing conversion

conversion to larger integral type may sign-extend incorrectly

-b
statement not reached (unreachable break and empty statements)
-h
assignment operator "=" found where equality operator "==" was expected

constant operand to op: "!"

fallthrough on case statements

pointer cast may result in improper alignment

precedence confusion possible; parenthesize

statement has no consequent: if

statement has no consequent: else

-m
declared global, could be static
-erroff=tag
One or more lint messages specified by tag
-u
name defined but never used

name used but not defined

-v
arguments unused in function
-x
name declared but never used or defined

4.4.2 lint Message Formats

The lint program can, with certain options, show precise source file lines with pointers to the line position where the error occurred. The option enabling this feature is -errfmt=f. Under this option, lint provides the following information:

For example, the following program, Test1.c, contains an error.

1 #include <string.h>
2 static void cpv(char *s, char* v, unsigned n)
3 { int i;
4   for (i=0; i<=n; i++){
5        *v++ = *s++;}
6 }
7 void main(int argc, char* argv[])
8 {
9     if (argc != 0){
10        cpv(argv[0], argc, strlen(argv[0]));}
11}

Using lint on Test1.c with the option:

% lint -errfmt=src -Nlevel=2 Test1.c

produces the following output:

      |static void cpv(char *s, char* v, unsigned n)
      |            ^  line 2, Test1.c
      |
      |         cpv(argv[0], argc, strlen(argv[0]));
      |                      ^  line 10, Test1.c
warning: improper pointer/integer combination: arg #2
      |
      |static void cpv(char *s, char* v, unsigned n)
      |                               ^  line 2, Test1.c
      |
      |cpv(argv[0], argc, strlen(argv[0]));
      |                       ^ line 10, Test1.c
      |
      |        *v++ = *s++;
      |         ^  line 5, Test1.c
warning:use of a pointer produced in a questionable way
    v defined at Test1.c(2)    ::Test1.c(5)
      call stack:
          main()                ,    Test1.c(10)
          cpv()                 ,    Test1.c(5)

The first warning indicates two source lines that are contradictory. The second warning shows the call stack, with the control flow leading to the error.

Another program, Test2.c, contains a different error:

1 #define AA(b) AR[b+l]
2 #define B(c,d) c+AA(d)
3
4 int x=0;
5
6 int AR[10]={1,2,3,4,5,6,77,88,99,0};
7
8 main()
9  {
10  int y=-5, z=5;
11  return B(y,z);
12 }

Using lint on Test2.c with the option:

% lint -errfmt=macro Test2.c

produces the following output, showing the steps of macro substitution:

      | return B(y,z);
      |        ^  line 11, Test2.c
      |
      |#define B(c,d) c+AA(d)
      |                 ^  line 2, Test2.c
      |
      |#define AA(b) AR[b+l]
      |                   ^  line 1, Test2.c
error: undefined symbol: l
|
      |    return B(y,z);
      |           ^  line 11, Test2.c
      |
      |#define B(c,d) c+AA(d)
      |                 ^  line 2, Test2.c
      |
      |#define AA(b) AR[b+l]
      |                   ^  line 1, Test2.c
variable may be used before set: l
lint: errors in Test2.c; no output created
lint: pass2 not run - errors in Test2.c