09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3<br />

lint: C PROGRAM CHEC KER<br />

This chapter explains how to use the C program checker lint. The program examines C<br />

source files and warns of errors or misconstructions that may cause errors during<br />

compilation of the file or during execution of the compiled file.<br />

In particular, lint checks for<br />

• Unused functions and variables<br />

• Unknown values in local variables<br />

• Unreachable statements and infinite loops<br />

• Unused and misused return values<br />

• Inconsistent types and type casts<br />

• Misma<strong>tc</strong>hed types in assignments<br />

• Nonportable and old-fashioned syntax<br />

• Strange constructions<br />

• Inconsistent pointer alignment and expression evaluation order<br />

The lint program and the C compiler are generally used together to check and compile C<br />

language programs. Although the C compiler rapidly and efficiently compiles C<br />

language source files, it does not perform the sophisticated type and error checking<br />

required by many programs. The lint program, on the other hand, provides thorough<br />

checking of source files without compiling.<br />

Invoking lint<br />

You can invoke lint by typing its name at the shell command prompt. The command has<br />

the form<br />

lint [ option ] ... filename ... lib ...<br />

where option is a command option that defines how the checker should operate,<br />

filename is the name of a C language source file to be checked, and lib is the name of a<br />

library to check. You can give more than one option, file name, or library name in the<br />

command as long as you use spaces to separate them. If you give two or more file<br />

names, lint assumes that the files form a complete program and checks the 'files<br />

accordingly. For example, the command<br />

lint main.c add.c<br />

3-1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!