delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/01/10:11:28

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: DJGPP and lint-like utility
Date: 1 Feb 2001 14:55:40 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 45
Message-ID: <95btdc$rda$1@nets3.rz.RWTH-Aachen.DE>
References: <95bbfn$qbp$1 AT saphir DOT jouy DOT inra DOT fr>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 981039340 28074 137.226.32.75 (1 Feb 2001 14:55:40 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 1 Feb 2001 14:55:40 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eric Wajnberg <wajnberg AT antibes DOT inra DOT fr> wrote:

> I am in need now for an utility program that can do an accurate check of the
> code before compiling it. Actually I need something like lint, wich is
> standard in all UNIX OS. 

To be precise: lint is standard in most *commercial* Unix OS. Linux
and FreeBSD, e.g., don't have it. There's lclint, but that's a tool
with quite a different approach than the original lint --- it tries to
enforce a whole programming style, if you crank it up to full warning
level. If that doesn't happen to be the style you like, you can easily
find yourself fighting against lclint more than it actually helps your
work.

> The use of -Wall is helpfull, but - as long as I've seen - it does not
> generate warnings if a parameter/function is declared and unused, etc.

GCC can do a lot more than you get from -Wall. Actually, -Wall is
explicitly documented to be a warning level that's supposed to enable
warnings that *always* make sense, no matter what the style and
history of that source is.

If you want a 'lint' emulation, you need a whole slew of further
options to GCC. Here's my personal favourite at this moment:

CFLAGS='-g -Wall -O2 \
 -Dgets=DONT_USE_GETS -Dscanf=DONT_USE_SCANF -Dlint -Wtraditional -Wshadow \
 -Wpointer-arith -Wnested-externs -Winline -W -Wstrict-prototypes \
 -Wmissing-prototypes -Wmissing-declarations'

(-Dlint is to comment out code blocks that have protection from the
real lint by an #ifndef lint ... #endif around them. That's customary
for the constructs carrying RCS/SCCS id strings, e.g.)

What even this can't do is check for possible problems that only occur
by using more than one source file.  For that, I got used to running
the freeware 'cxref' on the project's sources.  While meant to produce
a cross reference listing, originally, it also does a whole lot of
checks that can only be made by a tool that has an overview of the
whole source tree.  E.g., it will notice if you have a function or
variable made globally available by one module, but not used by any
other one, or even not at all.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019