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

Ian Lance Taylor ian@airs.com
Thu Mar 24 17:31:00 GMT 2005


"Vladimir Merzliakov" <wanderer@rsu.ru> writes:

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

Sorry, this patch is not OK.  It will just lead us down the path of
increasing the #ifdef over and over again.  The question here is why
HAVE_DECL_GETOPT is not defined.

Looking at gcc, I would say that the binutils configure.in file should
do the equivalent of gcc_AC_CHECK_DECLS(getopt) to get
HAVE_DECL_GETOPT defined appropriately.

Ian



More information about the Gcc-patches mailing list