checking man page includes and prototypes?

看板FB_doc作者時間19年前 (2006/06/15 00:21), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
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. -- 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 _______________________________________________ freebsd-doc@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-doc To unsubscribe, send any mail to "freebsd-doc-unsubscribe@freebsd.org"
文章代碼(AID): #14a3Ti00 (FB_doc)
文章代碼(AID): #14a3Ti00 (FB_doc)