From owner-freebsd-doc@FreeBSD.ORG Wed Jun 14 16:59:56 2006 Return-Path: X-Original-To: freebsd-doc@FreeBSD.org Delivered-To: freebsd-doc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B062F16A41A for ; Wed, 14 Jun 2006 16:59:56 +0000 (UTC) (envelope-from trhodes@FreeBSD.org) Received: from pittgoth.com (ns1.pittgoth.com [216.38.206.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D2C743D7D for ; Wed, 14 Jun 2006 16:59:55 +0000 (GMT) (envelope-from trhodes@FreeBSD.org) Received: from mobile.pittgoth.com (ip70-177-190-239.dc.dc.cox.net [70.177.190.239]) (authenticated bits=0) by pittgoth.com (8.13.4/8.13.4) with ESMTP id k5EH2kYM099371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 14 Jun 2006 13:02:47 -0400 (EDT) (envelope-from trhodes@FreeBSD.org) Date: Wed, 14 Jun 2006 12:59:45 -0400 From: Tom Rhodes To: Rich Morin Message-Id: <20060614125945.292e5329.trhodes@FreeBSD.org> In-Reply-To: References: X-Mailer: Sylpheed version 1.0.6 (GTK+ 1.2.10; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-doc@FreeBSD.org Subject: Re: checking man page includes and prototypes? X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jun 2006 16:59:56 -0000 On Wed, 14 Jun 2006 09:15:39 -0700 Rich Morin 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 > > long > sysconf(int name); > > I can turn this into the file test.c: > > #include > > 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