[quagga-dev 3571] Re: getopt decls considered kludgy
paul at clubi.ie
Tue Aug 9 16:46:52 BST 2005
Regarding the subject, strongly agree.
On Mon, 8 Aug 2005, Greg Troxel wrote:
> I hadn't tried to build quagga-head recently, and just tried and
> had several problems. One is that getopt is declared in
> lib/getopt.h, but this did not match the POSIX.2 declaration in
> unistd.h on NetBSD.
Right, we want the long argument version of getopt (the GNUish one?)
> I have made the following change to make POSIX.2 compliance the
> main path, with the notion of adding workarounds for any system
> which is STDC but does not comply with POSIX.2. (This follows from
> a philosophy of coding to standards first and then working around
> non-standard systems, rather than adjusting to each system as it is
Hmm, sounds good, but will you take care of the broken pieces? :)
> I'd like to get comments first before committing this. If anyone
> has an 'old' system (really a system with old header files), I'd
> appreciate trying this patch.
> -/* Many other libraries have conflicting prototypes for getopt, with
> - differences in the consts, in stdlib.h. To avoid compilation
> - errors, only prototype getopt for systems we know have compatible
> - getopt.
> - glibc: __GNU_LIBRARY__
> - solaris: __EXTENSIONS__
> - OpenBSD: _GETOPT_DEFINED_
> - FreeBSD: _GETOPT_DECLARED
> + * getopt is defined in POSIX.2. Assume that if the system defines
> + * getopt that it complies with POSIX.2. If not, an autoconf test
> + * should be written to define NONPOSIX_GETOPT_DEFINITION.
See the above. Though, at least at present we fail to compile rather
than risking compilation on an incompatible system.
The problem is, AFAICT (having been the last person to look at this),
there is no standard way to either enable long argument getopt or
tell whether the long argument getopt is enabled. At present we will
compile only on systems explicitely known to be compatible.
Also, will you write the autoconf test? :) If I could see that and it
was acceptable, I'd be in favour most likely.
Paul Jakma paul at clubi.ie paul at jakma.org Key ID: 64A2FF6A
I WILL NOT SPIN THE TURTLE
Bart Simpson on chalkboard in episode 8F21
More information about the Quagga-dev