The lint program is a static analyzer. It cannot evaluate the runtime consequences of the dependencies it detects. For example, certain programs might contain hundreds of unreachable break statements that are of little importance that lint flags nevertheless. For example, you could use the lint command-line options and special directives embedded as comments in the source text, as follows:
Invoking lint with the -b option suppresses all the error messages about unreachable break statements.
Precede any unreachable statement with the comment /*NOT REACHED*/ to suppress the diagnostic for that statement.
The lint options are listed below alphabetically. Several lint options relate to suppressing lint diagnostic messages. These options are also listed in Table 15, following the alphabetized options, along with the specific messages they suppress. The options for invoking enhanced lint begin with -N.
lint recognizes many cc command-line options, including -A, -D, -E, -g, -H, -O, -P, -U, -ansi, -std=value, -pedantic, -Xa, -Xc, -Xs, -Xt, and -Y, although -g and -O are ignored. Unrecognized options are warned about and ignored.
Enables verbose mode, showing each component as it is invoked.
Shows each component as it is invoked, but does not actually execute it.
Suppresses certain messages. Refer to Table 15.
Suppresses certain messages. Refer to Table 15.
Creates a .ln file with the file name specified. These .ln files are the product of lint’s first pass only. filename can be a complete path name.
Creates a .ln file consisting of information relevant to lint’s second pass for every .c file named on the command line. The second pass is not executed.
Specifies the directory dir where the lint output files (.ln files) will be placed. This option affects the -c option.
-err=warn is a macro for -errwarn=%all. See -errwarn=t.
Perform additional checking as specified by l. The default is -errchk=%none. Specifying -errchk is equivalent to specifying -errchk=%all. l is a comma-separated list of checks that consists of one or more of the flags in the following table, for example, -errchk=longptr64,structarg.
|
Specifies the format of lint output. f can be one of the following: macro, simple, src, or tab.
|
The default is -errfmt=tab. Specifying -errfmt is equivalent to specifying -errfmt=tab.
If more than one format is specified, the last format specified is used, and lint warns about the unused formats.
Enables lint to report certain messages for header files when you also specify -Ncheck. h is a comma-separated list that consists of one or more of the following: dir, no%dir, %all, %none, %user.
|
Examples:
% lint -errhdr=inc1 -errhdr=../inc2
Checks used header files in directories inc1 and ../inc2.
% lint -errhdr=%all,no%../inc
Checks all used header files except those in the directory ../inc.
Suppresses or enables lint error messages.
t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none.
|
The default is -erroff=%none. Specifying -erroff is equivalent to specifying -erroff=%all.
Examples:
% lint -erroff=%all,no%E_ENUM_NEVER_DEF,no%E_STATIC_UNUSED
Prints only the messages “enum never defined” and “static unused” and suppresses other messages.
% lint -erroff=E_ENUM_NEVER_DEF,E_STATIC_UNUSED
Suppresses only the messages “enum never defined” and “static unused”.
Use the -errsecurity option to check your code for security loopholes.
level must be one of the values shown in the following table.
If you do not specify a setting for -errsecurity, the lint sets it to -errsecurity=%none. If you do specify -errsecurity but not an argument, the lint sets it to -errsecurity=standard.
Displays the message tag for each error message. a can be either yes or no. The default is -errtags=no. Specifying -errtags is equivalent to specifying -errtags=yes.
Works with all -errfmt options.
If the indicated warning message is issued, lint exits with a failure status. t is a comma-separated list that consists of one or more of the following: tag, no%tag, %all, %none. The order of the tags is important. For example %all,no%tag causes lint to exit with a fatal status if any warning except tag is issued. The following table list the -errwarn values.
|
The default is -errwarn=%none. Specifying -errwarn alone is equivalent to -errwarn=%all.
Prints the path names as supplied on the command line rather than only their base names when referring to the .c files named on the command line.
Reports about old-style function definitions or declarations.
Executes lint with options contained in the file file. Multiple options can be specified in file, one per line.
Suppresses certain messages. Refer to Table 15.
Searches the directory dir for included header files.
Alter the behavior of /* LINTED [message] */ directives or NOTE(LINTED(message)) annotations. Normally, lint suppresses warning messages for the code following these directives. Instead of suppressing the messages, lint prints an additional message containing the comment inside the directive or annotation.
Searches for a lint library in the directory dir when used with -l.
Accesses the lint library llib-lx.ln.
Suppresses certain messages. Refer to Table 15.
Specifies the data type model for the program being analyzed. Also searches for lint libraries that correspond to the selected data type model (32-bit or 64-bit).
Use –m32 to verify 32-bit C programs and –m64 to verify 64-bit C programs.
The ILP32 data type model (32-bit int, long, pointer data types) is the default on all Oracle Solaris platforms and on Oracle Linux platforms that are not 64-bit enabled. The LP64 data type model (64-bit long, pointer data types) is the default on Oracle Linux platforms that are 64-bit enabled. –m64 is permitted only on platforms that are enabled for the LP64 model.
Checks header files for corresponding declarations, and checks macros. c is a comma-separated list of checks that consists of one or more of the following: macro, extern, %all, %none, no%macro, no%extern.
|
The default is -Ncheck=%none. Specifying -Ncheck is equivalent to specifying -Ncheck=%all.
Values may be combined with a comma, for example, -Ncheck=extern,macro.
The following example performs all checks except macro checks.
% lint -Ncheck=%all,no%macro
(Obsolete) The -Nlevel option will be removed in a future release.
Enables enhanced lint mode by specifying the level of enhanced lint analysis for reporting problems. This option provides control of the amount of errors detected. The higher the level, the longer the verification time. n is a number: 1, 2, 3, or 4. There is no default. If you do not specify -Nlevel, lint uses its basic analysis mode. If you specify -Nlevel without an argument, lint sets -Nlevel=4.
See Using lint for an explanation of basic and enhanced lint modes.
Analyzes single procedures. Reports unconditional errors that occur on some program execution paths. Does not do global data and control flow analysis.
Analyzes the whole program, including global data and control flow. Reports unconditional errors that occur on some program execution paths.
Analyzes the whole program, including constant propagation (cases when constants are used as actual arguments) as well as the analysis performed under -Nlevel=2.
Verification of a C program at this analysis level takes two to four times longer than at the preceding level. The extra time is required because lint assumes partial interpretation of the program by creating sets of possible values for program variables. These sets of variables are created on the basis of constants and conditional statements that contain constant operands available in the program. The sets form the basis for creating other sets (a form of constant propagation).
Sets received as the result of the analysis are evaluated for correctness according to the following algorithm:
If a correct value exists among all possible values of an object, then that correct value is used as the basis for further propagation; otherwise an error is diagnosed.
Analyzes the whole program, and reports conditional errors that could occur when certain program execution paths are used, as well as the analysis performed under -Nlevel=3.
At this analysis level, there are additional diagnostic messages. The analysis algorithm generally corresponds to the analysis algorithm of -Nlevel=3 with the exception that any invalid values now generate an error message. The amount of time required for analysis at this level can increase as much as two orders (about 20 to 100 times more slowly). In this case, the extra time required is directly proportional to the program complexity as characterized by recursion, conditional statements and the like. As a result using this level of analysis might be difficult for a program that exceeds 100,000 lines.
Suppresses checks for compatibility with the default lint standard C library.
Causes lint to create a lint library with the name llib-lx.ln. This library is created from all the .ln files that lint used in its second pass. The -c option nullifies any use of the -o option. To produce a llib-lx.ln without extraneous messages, you can use the-x option. The -v option is useful if the source files for the lint library are only external interfaces. The lint library produced can be used later if lint is invoked with -lx.
By default, you create libraries in lint’s basic format. If you use lint’s enhanced mode, the library created will be in enhanced format, and can only be used in enhanced mode.
Enables certain messages relating to portability issues.
Write a .ln file to file, for use by cxref(1). This option disables the enhanced mode if it is switched on.
Produce simple diagnostics with "warning:" or "error:" prefixes. By default lint buffers some messages to produce compound output.
Suppresses certain messages. Refer to Table 15. This option is suitable for running lint on a subset of files of a larger program.
Writes the product name and releases to standard error.
Suppresses certain messages. Refer to Table 15.
Write a .ln file to file, for use by cflow(1). This option disables the enhanced mode if it is switched on.
Accepts C++-style comments. In particular, // can be used to indicate the start of a comment. a can be either yes or no. The default is -XCC=no. Specifying -XCC is equivalent to specifying -XCC=yes.
With this option,l is one of any, basic, weak, layout, strict, std, or strong. See Table 49 for a detailed explanation of the different levels of disambiguation.
If you do not specify -Xalias_level, the default of the flag is -Xalias_level=any, which means that no type-based alias-analysis is performed. If you specify -Xalias_level but do not supply a level, the default is -Xalias_level=layout.
Be sure to run lint at a level of disambiguation that is no more strict than the level at which you ran the compiler. If you run lint at a level of disambiguation that is more strict than the level at which you compiled, the results will be difficult to interpret and possibly misleading.
See lint Filters for a detailed explanation of disambiguation as well as a list of pragmas designed to help with disambiguation.
(Oracle Solaris) Deprecated. Do not use. See -m32|-m64.
The -Xc99 flag controls compiler recognition of the implemented features from the C99 standard (ISO/IEC 9899:1999, Programming Language -C).
o can be one of the following: all, none.
-Xc99=none disables recognition of C99 features. -Xc99=all enables recognition of supported C99 features.
Specifying -Xc99 without any arguments is the same as -Xc99=all.
The -Xc99 flag cannot be used if the -std or -pedantic flag has been specified.
Keeps temporary files created during linting instead of deleting them automatically. a can be either yes or no. The default is -Xkeeptmp=no. Specifying -Xkeeptmp is equivalent to specifying -Xkeeptmp=yes.
Sets the directory for temporary files to dir. Without this option, temporary files go into /tmp.
Reports the execution time for each lint pass. a can be either yes or no. The default is -Xtime=no. Specifying -Xtime is equivalent to specifying -Xtime=yes.
Issues warnings for the differences between K&R C and Oracle Developer Studio ISO C. a can be either yes or no. The default is -Xtransition=no. Specifying -Xtransition is equivalent to specifying -Xtransition=yes.
This option enables recognition of string literals of the form U"ASCII-string" as an array of unsigned short int. The default is -Xustr=no, which disables compiler recognition of U"ASCII-string string literals. "-Xustr=ascii_utf16_ushort enables compiler recognition of U"ASCII-string" string literals.
Suppresses certain messages. Refer to Table 15.
Treats every .c file named on the command line as if it begins with the directive /* LINTLIBRARY */ or the annotation NOTE(LINTLIBRARY). A lint library is normally created using the /* LINTLIBRARY */ directive or the NOTE(LINTLIBRARY) annotation.