Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Oct 95 11:39:56 CDT
From:      Tim Pierce <twpierce@midway.uchicago.edu>
To:        questions@freebsd.org
Cc:        twpierce@midway.uchicago.edu
Subject:   POSIX status of getopt(3)
Message-ID:  <CMM.0.90.4.814207196.twpierce@kimbark.uchicago.edu>

next in thread | raw e-mail | index | archive | help

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 <stdlib.h>
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CMM.0.90.4.814207196.twpierce>