[prev] [up] [overview] [next]

Section 13. Lint

13.1: I just typed in this program, and it's acting strangely.  Can you see anything wrong with it?

Try running lint first (perhaps with the -a, -c, -h, -p and/or other options).  Many C compilers are really only half- compilers, electing not to diagnose numerous source code difficulties which would not actively preclude code generation.

13.2: How can I shut off the "warning: possible pointer alignment problem" message lint gives me for each call to malloc?

The problem is that traditional versions of lint do not know, and cannot be told, that malloc "returns a pointer to space suitably aligned for storage of any type of object."  It is possible to provide a pseudoimplementation of malloc, using a #define inside of #ifdef lint, which effectively shuts this warning off, but a simpleminded #definition will also suppress meaningful messages about truly incorrect invocations.  It may be easier simply to ignore the message, perhaps in an automated way with grep -v.

13.3: Where can I get an ANSI-compatible lint?

A product called FlexeLint is available (in "shrouded source form," for compilation on 'most any system) from

Gimpel Software
3207 Hogarth Lane
Collegeville, PA  19426 USA
(+1) 610 584 4261

The System V release 4 lint is ANSI-compatible, and is available separately (bundled with other C tools) from UNIX Support Labs, or from System V resellers.

Another ANSI­compatible lint (which can also perform higher­level formal verification) is LCLint, available via anonymous ftp from larch.lcs.mit.edu://pub/Larch/lclint/.

In the absence of lint, many modern compilers attempt to diagnose almost as many problems as a good lint does.

[prev] [up] [overview] [next]