From owner-freebsd-questions Fri Oct 20 09:40:40 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id JAA10226 for questions-outgoing; Fri, 20 Oct 1995 09:40:40 -0700 Received: from midway.uchicago.edu (midway.uchicago.edu [128.135.12.73]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id JAA10221 for ; Fri, 20 Oct 1995 09:40:37 -0700 Received: from kimbark.uchicago.edu (kimbark.uchicago.edu [128.135.12.52]) by midway.uchicago.edu (8.6.10/8.6.4) with ESMTP id LAA15406; Fri, 20 Oct 1995 11:40:29 -0500 Received: (twpierce@localhost) by kimbark.uchicago.edu (8.6.10/8.6.4) id LAA22378; Fri, 20 Oct 1995 11:39:56 -0500 Date: Fri, 20 Oct 95 11:39:56 CDT From: Tim Pierce To: questions@freebsd.org Subject: POSIX status of getopt(3) Cc: twpierce@midway.uchicago.edu Message-ID: Sender: owner-questions@freebsd.org Precedence: bulk Hi, folks: I'm sorry to bother you with this, but I've asked twice in comp.unix.bsd.freebsd.misc and had no response, and I could find no pointer to this discussion in the archives. This question has some relevance to the MGR window system, which I'm trying to port to FreeBSD. I'm running 2.0R. (Yes, I know I should upgrade, but at present my only method of doing so is via floppy disk, and I have other priorities at the moment.) In stdlib.h, if the macro _POSIX_SOURCE is defined, then `optarg' and `getopt' (among other symbols) are not defined or declared: #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) ... extern char *optarg; extern int opterr, optind, optopt; int getopt __P((int, char * const *, const char *)); Yet the man page for getopt(3) implies that it's acceptable to use it in a POSIX environment. EXTENSIONS The `optreset' variable was added to make it possible to call the getopt() function multiple times. This is an extension to the IEEE Std1003.2 (``POSIX'') specification. Can any of you shed some light on this? Should actually be declaring optarg, optind and the rest? Or if I'm compiling with _POSIX_SOURCE turned on, should I expect these to be defined/declared somewhere else? Thanks for any suggestions you can lend -- love, T.