Path: utzoo!attcan!uunet!ingr! From: rcl@b15.INGR.COM (Rob Lemley) Newsgroups: comp.lang.c Subject: Re: Why use (void) func() ? (lint beef) Message-ID: <1735@b15.INGR.COM> Date: 4 Oct 90 22:07:59 GMT References: <586@dptechno.UUCP> <1990Sep24.193012.14074@diku.dk> <12141@crdgw1.crd.ge.com> <151806@felix.UUCP> Organization: Intergraph Huntsville Lines: 114 th: b15!rcl In <151806@felix.UUCP> asylvain@felix.UUCP (Alvin E. Sylvain) writes: >Anyone else out there feel this way? Any thoughts toward a version >of lint that's a little less "mother-hen", but still tells you what >you need to know? Maybe we could program it with "ignore the following >problems with the following functions" instructions. I admit, this has been, and probably will continue to be, a problem with lint. A modular, customizable system (ahh Unix) is one answer that we now have. On System V Release 3, a great deal of customization can be done with the current lint. You must be willing to edit system include files (in /usr/include) and the lint libraries (usually in /usr/lib). Of course, this should be done in a local directory before installing changes in the system area. The following type script of a work session illustrates how this can be accomplished. Note that lint itself is a shell script which you may examine at your leisure :-). The last lint command in the sequence: lint -u -n -I. -L. -lc t.c uses an undocumented option of lint, the -L option, which specifies search directories where lint libraries should be found. Here is a description of the options used: -u Suppress complaints about functions and external variables used and not defined, or defined and not used. (This option is used because some new functions were added to the stdio.h file and not added to the lint library file.) -n Do not check compatibility against either the standard or the portable lint library. -I. Search for header files in the current directory before /usr/include, etc. -L. This is the undocumented option to lint which creates and adds directories to the search list for lint libraries. -lc Since the directory search list for lint libraries has now been defined, this option tells lint to use the c library lint library. (which will be found in the current directory.) Type script of work session (I have added blank lines before the prompts): $ cat t.c #include main() { printf ("hello world\n"); return 0; } $ lint -u t.c ============== function returns value which is always ignored printf $ diff /usr/lib/llib-lc ./llib-lc.c 381c381 < int printf(s) char *s; { return (0); } --- > void printf(s) char *s; { return ; } $ diff /usr/include/stdio.h ./stdio.h 153c153 < extern int printf(const char *format, ...); --- > extern void printf(const char *format, ...); 189c189 < getw(), pclose(), printf(), fprintf(), sprintf(), --- > getw(), pclose(), fprintf(), sprintf(), 192a193 > extern void printf(); $ lint -n -v -x -I. llib-lc.c -o c "/usr/include/mon.h", line 30: warning: redefinition of: NULL llib-lc.c ============== (484) warning: struct/union region never defined $ lint -u -n -I. -L. -lc t.c $ End of work session type script. The fact that lint is a shell script also lends many possibilities for local customization. Another way to alleviate the problem of too much unnecessary output from lint would be to use some kind of post-processing. When I was using the BSD 4.1 system, we had a utility called "error" which would take the standard and/or error output of cc, cpp, lint, f77, etc. and insert special comments in the source files at the lines where errors were detected. The error command also would read a startup file ($HOME/.ignore or something like that) where you could specify errors that you wanted to be ignored. This is where I specified that I didn't want to here about printf(), exit(), etc. -- -Rob Lemley System Consultant, Scanning Software, Intergraph, Huntsville, AL ...!uunet!ingr!b15!rcl or b15!rcl@INGR.COM 205-730-1546