Path: utzoo!attcan!uunet!lll-winken!uwm.edu!zaphod.mps.ohio-state.edu!samsung!emory!audfax!arnold From: arnold@audiofax.com (Arnold Robbins) Newsgroups: comp.lang.c Subject: Re: ANSI C lint type tool wanted Keywords: lint ANSI ansi C gcc Message-ID: <249@audfax.audiofax.com> Date: 31 Jul 90 15:56:01 GMT References: <6568@tekcrl.LABS.TEK.COM> Organization: AudioFAX Inc., Atlanta Lines: 53 In article <6568@tekcrl.LABS.TEK.COM> markh@tekcrl.LABS.TEK.COM (Mark C Henderson) writes: >We are looking for an ANSI C lint. > >gcc -Wall won't do what we want. In particular it doesn't cover what >is covered by pass 2 in SUN OS lint, i.e. checking the consistency of >declarations across files. > >Is their a way to coax gcc into doing this? Having gone through this recently... the following steps will go a long way towards what you want. First though, our functions are all declared like so: int name(int p1, float p2 /* and so on */) { code here } This one line awk script will remove all function bodies from your code. cat *.c | awk '/^{/,/^}/ { next } ; /./' > protos.h Leaving you all the global declarations. Edit these into a header file of prototypes and externs that every .c file includes. Next, # create files with lists of function names for i in *.c do grep '^[A-Za-z0-9_][A-Za-z0-9_]*(' $i | sed 's/(.*//' > $i.i done # count the number of files each identifier appears in for i in *.i do for j in `cat $i` do k=`grep -l $j *.c | wc -l` if [ $k = 1 ] then echo $j in $i could be static fi done done This gives you a list of routines that could be made static. Make the appropriate changes in your source files and the header with all the prototypes. Recompile with gcc -Wall and remove any other problems. This does not duplicate lint's full functionality, but it certainly helps. I too miss having an ANSI lint. -- Arnold Robbins AudioFAX, Inc. | Laundry increases 2000 Powers Ferry Road, #220 / Marietta, GA. 30067 | exponentially in the INTERNET: arnold@audiofax.com Phone: +1 404 933 7600 | number of children. UUCP: emory!audfax!arnold Fax: +1 404 933 7606 | -- Miriam Robbins