From owner-freebsd-doc@FreeBSD.ORG Wed Jun 14 16:14:12 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 3339D16A479 for ; Wed, 14 Jun 2006 16:14:12 +0000 (UTC) (envelope-from rdm@cfcl.com) Received: from cfcl.com (cpe-24-221-172-174.ca.sprintbbd.net [24.221.172.174]) by mx1.FreeBSD.org (Postfix) with ESMTP id ECFCB43D5D for ; Wed, 14 Jun 2006 16:14:07 +0000 (GMT) (envelope-from rdm@cfcl.com) Received: from [192.168.254.205] ([192.168.254.205]) by cfcl.com (8.12.6/8.12.6) with ESMTP id k5EGJ4vH095871 for ; Wed, 14 Jun 2006 09:19:08 -0700 (PDT) (envelope-from rdm@cfcl.com) Mime-Version: 1.0 Message-Id: Date: Wed, 14 Jun 2006 09:15:39 -0700 To: freebsd-doc@freebsd.org From: Rich Morin Content-Type: text/plain; charset="us-ascii" Subject: 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:14:12 -0000 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. -- http://www.cfcl.com/rdm Rich Morin http://www.cfcl.com/rdm/resume rdm@cfcl.com http://www.cfcl.com/rdm/weblog +1 650-873-7841 Technical editing and writing, programming, and web development