16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Development Tools<br />

/* compute size of increment to next stop */<br />

int findstop(int col)<br />

{<br />

return (TABSIZE – (col * TABSIZE) );<br />

}<br />

LINT<br />

A C program checker/verifier. Attempts to detect features that are likely to be:<br />

- execution errors – detects bugs<br />

- non-portable<br />

- wasteful of resources – obscurities<br />

Also inconsistencies in code:<br />

- unreachable statements<br />

- loops not entered at top<br />

- automatic variables declared and not used<br />

- logical expressions that are constant<br />

- return values in functions<br />

- number of argument in functions<br />

- function values changed but not returned<br />

- checks consistency <strong>with</strong> libraries<br />

- enforce type-checking rules more strictly<br />

- find legal constructions that may produce errors used for portability<br />

usage:<br />

lint [options] files libraries<br />

options:<br />

-a suppress messages about assignments of long values to variables that are not long<br />

-b suppress messages about break statements that can not be reached<br />

consult "man lint"<br />

INDENT<br />

Indent and format C program source. It reformats <strong>the</strong> C program in <strong>the</strong> input-file according to switches:<br />

indent [ input-file [ output-file ] ) [ switches ]<br />

If you only specify an input-file, formatting is written back into <strong>the</strong> input file (a backup is made in file.BAK)<br />

There are options to place blank lines before or after various blocks of code: -bap -bad,<br />

-bbb, -bc<br />

You may turn off <strong>the</strong> -bc option <strong>with</strong> -nbc.<br />

Control <strong>the</strong> layout of compound statements: -br, -bl, -brr<br />

if (...)<br />

{/* -br option */<br />

code<br />

}<br />

The layout of comments: -cn, -cdn, -cdn<br />

CTAGS<br />

Create a tags file for "vi". Each line of <strong>the</strong> tags file contains <strong>the</strong> object name, file in which it is defined, and an<br />

address specification for <strong>the</strong> object definition<br />

-x causes ctags to print a simple function index: function name, filename, line number, text of line to standard<br />

output (no tags file is created)<br />

C Compiler<br />

Example:<br />

$ cc -c main.c filel.c file2.c<br />

54

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

Saved successfully!

Ooh no, something went wrong!