[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getopt compilation problem
From: |
Eric Blake |
Subject: |
Re: getopt compilation problem |
Date: |
Mon, 5 Oct 2009 19:58:45 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Reuben Thomas <rrt <at> sc3d.org> writes:
> Using getopt-posix on FreeBSD 6, with current git gnulib, I get the
> following compilation error:
>
> /usr/bin/cc -std=gnu99 -DHAVE_CONFIG_H -I. -I..
> -I/usr/local/include -Wall -W -Wmissing-prototypes -Wstrict-prototypes
> -D_FORTIFY_SOURCE=2 -MT getopt.o -MD -MP -MF .deps/getopt.Tpo -c -o
> getopt.o getopt.c
> In file included from getopt.c:62:
> getopt_int.h:25: error: conflicting types for '_getopt_internal'
> /usr/local/include/getopt.h:128: error: previous declaration of
> '_getopt_internal' was here
Sounds like two independent implementations picked the same internal name.
FreeBSD probably shouldn't have exposed their internal name inside their public
<getopt.h>, but since they did, we'll have to work around it.
Does this (as-yet-untested) patch work for you?
diff --git i/ChangeLog w/ChangeLog
index e3b25c6..557655e 100644
--- i/ChangeLog
+++ w/ChangeLog
@@ -1,5 +1,10 @@
2009-10-05 Eric Blake <address@hidden>
+ getopt: avoid clash with FreeBSD _getopt_internal
+ * lib/getopt.in.h (_getopt_internal): Override the name.
+ * lib/getopt_int.h (includes): Pick up any overrides.
+ Reported by Reuben Thomas.
+
hash: allow C89 compilation
* lib/hash.c (check_tuning): Move declaration before statement.
Reported by Reuben Thomas.
diff --git i/lib/getopt.in.h w/lib/getopt.in.h
index 15c213f..9de467a 100644
--- i/lib/getopt.in.h
+++ w/lib/getopt.in.h
@@ -68,6 +68,7 @@
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
# define option __GETOPT_ID (option)
+# define _getopt_internal __GETOPT_ID (getopt_internal)
#endif
/* Standalone applications get correct prototypes for getopt_long and
diff --git i/lib/getopt_int.h w/lib/getopt_int.h
index 3c6628b..69cdf0d 100644
--- i/lib/getopt_int.h
+++ w/lib/getopt_int.h
@@ -1,5 +1,5 @@
/* Internal declarations for getopt.
- Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,6 +19,8 @@
#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H 1
+#include <getopt.h>
+
extern int _getopt_internal (int ___argc, char **___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,