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.

<strong>XENIX</strong> Programming cc: C Compiler<br />

You can avoid many C compiler errors by using the <strong>XENIX</strong> C program checker lint<br />

before compiling your C source files. lint performs detailed error checking on a source<br />

file and provides a list of actual errors and possible problems that may affect execution<br />

of the program. For a description of lint, see Chapter 3, "lint: C Program Checker."<br />

Setting the Level of Warnings<br />

You can set the level of warning messages produced by the compiler by using the -W<br />

option. This option directs the compiler to display messages about statements that may<br />

not be compiled as the programmer intends. Warnings indicate potential problems<br />

rather than actual errors. The option has the form<br />

-W number<br />

where number is a number in the range 0 to 3 giving the level of warnings. The levels<br />

are<br />

0 Suppresses all warning messages. Only messages about actual syntactic or<br />

semantic errors are displayed.<br />

1 Warns about potentially missing statements, unreachable statements, and<br />

other structural problems. Also warns about overt type misma<strong>tc</strong>hes.<br />

2 Warns about all type misma<strong>tc</strong>hes (strong typing).<br />

3 Warns on all automatic data conversions.<br />

If the option is not used, the default is level 1.<br />

The higher option levels are especially useful in the earlier stages of program<br />

development when messages about potential problems are most helpful. The lower<br />

levels are best for compiling programs whose questionable statements are intentionally<br />

designed. For example, the command<br />

cc -W 3 mai n.c<br />

directs the compiler to perform the highest level of checking and produces the greatest<br />

number of warning messages. The command<br />

cc -W 0 · main.c<br />

produces no warning messages. Note that the -w option has the same effect as -W 0.<br />

2-15

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

Saved successfully!

Ooh no, something went wrong!