Date: Wed, 14 Jun 2006 12:59:45 -0400 From: Tom Rhodes <trhodes@FreeBSD.org> To: Rich Morin <rdm@cfcl.com> Cc: freebsd-doc@FreeBSD.org Subject: Re: checking man page includes and prototypes? Message-ID: <20060614125945.292e5329.trhodes@FreeBSD.org> In-Reply-To: <p062309d5c0b5e6114077@[192.168.254.205]> References: <p062309d5c0b5e6114077@[192.168.254.205]>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 14 Jun 2006 09:15:39 -0700 Rich Morin <rdm@cfcl.com> wrote: > I'm doing a lot of editing of section 2 and 3 man pages, > concentrating on the includes and prototypes. Although > I'm trying to be careful, it's quite likely that some > errors will slip past me. So, I'm casting about for a > way to do an automated sanity check. Here's one idea: > > For each man page > For each prototype > Construct a C test file. > Compile the test file. > Look for nastygrams, etc. > > For example, the sysconf(3) SYNOPSIS contains the lines: > > #include <unistd.h> > > long > sysconf(int name); > > I can turn this into the file test.c: > > #include <unistd.h> > > main() { > > int name; > sysconf(name); > } > > Compiling this (e.g., "cc test.c") finishes silently. > So far, so good... > > > Editing "sysconf" into "sysconfx" produces a promising > nastygram: > > /usr/bin/ld: Undefined symbols: > _sysconfx > collect2: ld returned 1 exit status > > > However, editing "int name;" into "float name;' does > NOT cause a nastygram. So, it appears that prototype > checking is not being done. The gcc(1) man page gave > me the idea of trying > > gcc -pedantic -ansi test.c > > but this didn't make any visible difference. I see a > bazillion other options, including a bunch of "-W..." > goodies, but I'd rather not try them all at random. I > tried "gcc -pedantic -ansi -Wstrict-prototypes test.c", > but it only complained about my "main" statement (?): > > test.c:3: warning: function declaration isn't a prototype > > > Any suggestions (general or specific) on how I might be > able to cajole gcc (or whatever) into helping me? > > -r > > P.S. The "obvious" strategy of inspecting the header file(s) > breaks down under closer examination. The declaration > may be located in an include file which is referenced > indirectly, #defines or #ifdefs may be involved, etc. > > So, for a general, automated solution, I'd like to rely > on the compiler (etc) to tell me whether the usage is > complete and correct. Have you tried using cc with -Wall? Lemmie sleep some and I might come up with something else. -- Tom Rhodes
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060614125945.292e5329.trhodes>