This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix binutils build problem at FreeBSD (fix warning in getopt.h)


After patch http://sourceware.org/ml/binutils-cvs/2005-03/msg00191.html
binutils build broken at FreeBSD 5.3

Build terminate with message:

In file included from
/usr/home/wanderer/pkg/build/binutils/src/src/binutils/size.c:34:
/usr/home/wanderer/pkg/build/binutils/src/src/binutils/../include/getopt.h:116:
warning: function declaration isn't a prototype

Same warnings will be generated by gcc for any C file with including both libiberty getopt.h and FreeBSD unistd.h
headers.


I check FreeBSD CVS and found getopt prototype added in 1994 to stdlib.h FreeBSD system header
and this prototype is same as in libiberty getopt.h
(in current FreeBSD CVS version getopt propotype in unistd.h).


And then I think adding defined(__FreeBSD__) in getopt prototype guarding #ifdef is safe and fix warning.
===================================================
--- include/getopt.h.old Sun Oct 27 04:00:34 2002
+++ include/getopt.h Thu Mar 24 17:23:31 2005
@@ -106,10 +106,10 @@
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if !HAVE_DECL_GETOPT
-#if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT)
+#if defined (__GNU_LIBRARY__) || defined (__FreeBSD__) || defined (HAVE_DECL_GETOPT)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in unistd.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
+ errors, only prototype getopt for the GNU C library and FreeBSD. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else
#ifndef __cplusplus
--- include/ChangeLog.old Thu Mar 24 17:47:12 2005
+++ include/ChangeLog Thu Mar 24 17:48:57 2005
@@ -1,3 +1,7 @@
+2005-03-24 Vladimir Merzlikov <wanderer@rsu.ru>
+
+ * getopt.h (getopt): Make correct prototype accessable for __FreeBSD__.
+
2005-03-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>


* libiberty.h (make_relative_prefix): Add ATTRIBUTE_MALLOC.

===================================================

binutils CVS mainline build and gcc CVS mainline bootstrap
with patch  at FreeBSD 5.3 without problems .

Vladimir


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]