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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

lint: C Program Checker <strong>XENIX</strong> Programming<br />

treats main.c and add.c as two parts of a complete program.<br />

If lint discovers errors or inconsistencies in a source file, it produces messages<br />

describing the problem. The message has the form<br />

filename ( num ) : description<br />

where filename is the name of the source file containing the problem, num is the<br />

number of the line in the source containing the problem, and description is a description<br />

of the problem. For example, the message<br />

main.c (3): warning: x unused in function main<br />

shows that the variable x, defined in line 3 of the source file main.c, is not used<br />

anywhere in the file.<br />

Checking for Unused Variables and Functions<br />

The lint program checks for unused variables and functions by seeing if each declared<br />

variable and function is used at least once in the source file. The program considers a<br />

variable or function used if the name appears in at least one statement. It is not<br />

considered used if it only appears on the left side of an assignment. For example, in the<br />

following program fragment<br />

main ()<br />

{<br />

int x, y, z;<br />

X= 1; y = 2; Z =X+ y;<br />

the variables x and y are considered used, but variable z is not.<br />

Unused variables and functions often occur during the development of large programs. It<br />

is not uncommon for a programmer to remove all references to a variable or function<br />

from a source file but forget to remove its declaration. Such unused variables and<br />

functions rarely cause working programs to fail but do make programs harder to<br />

understand and change. Checking for unused variables and functions can also help you<br />

find variables or functions that you intended to used but have accidentally left out of<br />

the program.<br />

3-2

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

Saved successfully!

Ooh no, something went wrong!