diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-11-23 02:50:54 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2004-11-23 02:50:54 +0000 |
commit | df81465613d8cda39a02d16aa62c0db476349fac (patch) | |
tree | 40a114426585d7f28eb4cae069a97e4f1bdc3c63 /lib/getopt_.h | |
parent | 2119b9a0051c83a0d08858f5c91a8d9104c0dcf6 (diff) | |
download | gnulib-df81465613d8cda39a02d16aa62c0db476349fac.tar.gz |
Re-addition of __getopt_argv_const caused
redefinition warnings. To avoid them, include the defines
in `#if !defined __need_getopt ... #endif'. The only place
where __getopt_argv_const is used is in definitions
of getopt_long and getopt_long_only below, which are as well
protected by `#ifndef __need_getopt'.
[defined __GETOPT_PREFIX && !defined __need_getopt]: Undef
__need_getopt after including <stdio.h> and <unistd.h> These
headers might have defined it.
Diffstat (limited to 'lib/getopt_.h')
-rw-r--r-- | lib/getopt_.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/getopt_.h b/lib/getopt_.h index efae5aa695..83ac8b1284 100644 --- a/lib/getopt_.h +++ b/lib/getopt_.h @@ -37,6 +37,7 @@ # if HAVE_UNISTD_H # include <unistd.h> # endif +# undef __need_getopt # undef getopt # undef getopt_long # undef getopt_long_only @@ -60,11 +61,24 @@ getopt_long_only; they declare "char **argv". libc uses prototypes with "char *const *argv" that are incorrect because getopt_long and getopt_long_only can permute argv; this is required for backward - compatibility (e.g., for LSB 2.0.1). */ -#if defined __GETOPT_PREFIX && !defined __need_getopt -# define __getopt_argv_const /* empty */ -#else -# define __getopt_argv_const const + compatibility (e.g., for LSB 2.0.1). + + This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', + but it caused redefinition warnings if both unistd.h and getopt.h were + included, since unistd.h includes getopt.h having previously defined + __need_getopt. + + The only place where __getopt_argv_const is used is in definitions + of getopt_long and getopt_long_only below, but these are visible + only if __need_getopt is not defined, so it is quite safe to rewrite + the conditional as follows: +*/ +#if !defined __need_getopt +# if defined __GETOPT_PREFIX +# define __getopt_argv_const /* empty */ +# else +# define __getopt_argv_const const +# endif #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used |