From corecode@corecode.ath.cx  Fri Aug 23 02:51:50 2002
Return-Path: <corecode@corecode.ath.cx>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4E60537B400
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Aug 2002 02:51:50 -0700 (PDT)
Received: from mailout11.sul.t-online.com (mailout11.sul.t-online.com [194.25.134.85])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 968A143E3B
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Aug 2002 02:51:49 -0700 (PDT)
	(envelope-from corecode@corecode.ath.cx)
Received: from fwd11.sul.t-online.de 
	by mailout11.sul.t-online.com with smtp 
	id 17iB6Z-00007M-03; Fri, 23 Aug 2002 11:51:47 +0200
Received: from spirit.zuhause.stoert.net (320050403952-0001@[217.224.174.249]) by fmrl11.sul.t-online.com
	with esmtp id 17iB6J-0Ul0AiC; Fri, 23 Aug 2002 11:51:31 +0200
Received: from terrorfish.uni.stoert.net (terrorfish.uni.stoert.net [10.150.180.178])
	by spirit.zuhause.stoert.net (8.11.6/8.11.6) with ESMTP id g7N9pRk04172
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Aug 2002 11:51:27 +0200 (CEST)
	(envelope-from corecode@corecode.ath.cx)
Received: from terrorfish.uni.stoert.net (localhost [127.0.0.1])
	by terrorfish.uni.stoert.net (8.12.5/8.12.5) with ESMTP id g7N9oXFh000778
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 23 Aug 2002 11:50:33 +0200 (CEST)
	(envelope-from corecode@terrorfish.uni.stoert.net)
Received: (from corecode@localhost)
	by terrorfish.uni.stoert.net (8.12.5/8.12.5/Submit) id g7N9oXDs000777;
	Fri, 23 Aug 2002 11:50:33 +0200 (CEST)
	(envelope-from corecode)
Message-Id: <200208230950.g7N9oXDs000777@terrorfish.uni.stoert.net>
Date: Fri, 23 Aug 2002 11:50:33 +0200 (CEST)
From: "Simon 'corecode' Schubert" <corecode@corecode.ath.cx>
Reply-To: "Simon 'corecode' Schubert" <corecode@corecode.ath.cx>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: declaration clash for ffs() and ${CXX}
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         41930
>Category:       kern
>Synopsis:       declaration clash for ffs() and ${CXX}
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 23 03:00:07 PDT 2002
>Closed-Date:    Sat Mar 28 23:20:11 UTC 2009
>Last-Modified:  Sat Mar 28 23:20:11 UTC 2009
>Originator:     Simon 'corecode' Schubert
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD terrorfish.uni.stoert.net 5.0-CURRENT FreeBSD 5.0-CURRENT #26: Tue Aug 20 13:57:01 CEST 2002 corecode@terrorfish.uni.stoert.net:/usr/obj/k7/usr/src/sys/TERRORFISH i386


	
>Description:
	when including both <string.h> and <machine/cpufunc.h> from a C++
	source, gcc yields a declaration error:
	
In file included from ffstest.cc:3:
/usr/include/machine/cpufunc.h: In function `int ffs(int)':
/usr/include/machine/cpufunc.h:109: `int ffs(int)' was declared `extern' and 
   later `static'
/usr/include/strings.h:44: previous declaration of `int ffs(int)'
	
>How-To-Repeat:
% cat > ffstest.cc <<__EOF__ && cc ffstest.cc
#include <string.h>
#include <sys/types.h>
#include <machine/cpufunc.h>
__EOF__
	
>Fix:
	don't know
	


>Release-Note:
>Audit-Trail:

From: Edwin Groothuis <edwin@mavetju.org>
To: freebsd-gnats-submit@FreeBSD.org, corecode@corecode.ath.cx
Cc:  
Subject: i386/41930: declaration clash for ffs() and ${CXX}
Date: Tue, 19 Nov 2002 11:01:56 +1100

 I ran into the same problem today with ports/audio/mpmf20.
 
 machine/cpufunc.h does set a flag if it has has been processed:
 HAVE_INLINE_FFS (line 106 of /usr/include/machine/cpufunc.h).
 
 So strings.h could be modified to:
  __BEGIN_DECLS
  int      bcmp(const void *, const void *, size_t);      /* LEGACY */
  void     bcopy(const void *, void *, size_t);           /* LEGACY */
  void     bzero(void *, size_t);                         /* LEGACY */
 +#ifndef HAVE_INLINE_FFS
  int      ffs(int);
 +#endif
  char    *index(const char *, int);                      /* LEGACY */
  char    *rindex(const char *, int);                     /* LEGACY */
  int      strcasecmp(const char *, const char *);
  int      strncasecmp(const char *, const char *, size_t);
  __END_DECLS
 
 
 Show stopper? Not really. Annoying? Yes. Worth fixing? YES!
 
 Edwin
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.MavEtJu.org
 edwin@mavetju.org    |    Weblog: http://www.mavetju.org/weblog/weblog.php 
 bash$ :(){ :|:&};:   | Interested in MUDs? http://www.FatalDimensions.org/

From: Ceri Davies <ceri@FreeBSD.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Sun, 25 May 2003 18:55:17 +0100

 Adding to audit trail, from misfiled PR i386/52457:
 
 Date: Tue, 20 May 2003 09:47:54 +0200
 From: Volker Stolz <stolz@i2.informatik.rwth-aachen.de>
 Message-Id: <20030520074754.GA95715@i2.informatik.rwth-aachen.de>
 References: <200208230950.g7N9oXDs000777@terrorfish.uni.stoert.net>
 
  On Fri, Aug 23, 2002 at 11:50:33AM +0200, Simon 'corecode' Schubert wrote:
  > >Description:
  > 	when including both <string.h> and <machine/cpufunc.h> from a C++
  > 	source, gcc yields a declaration error:
  > 
  > From: Edwin Groothuis <edwin@mavetju.org>
  >  I ran into the same problem today with ports/audio/mpmf20.
  >  machine/cpufunc.h does set a flag if it has has been processed:
  >  HAVE_INLINE_FFS (line 106 of /usr/include/machine/cpufunc.h).
  >  
  >  So strings.h could be modified  [...]
  
  I've just been bit by another instance of this (hpoj-printer driver
  port). Are there any intentions to fix this RSN? Is there somebody
  specific who could be contacted about this issue?
  I'm cc:ing mike@ who last touched strings.h.
  
  Regards,
    Volker
 

From: Ceri Davies <ceri@FreeBSD.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Sun, 25 May 2003 18:55:40 +0100

 Adding to audit trail, from misfiled PR i386/52458:
 
 Date: Tue, 20 May 2003 17:57:08 +1000
 From: Edwin Groothuis <edwin@mavetju.org>
 Message-Id: <20030520075708.GK605@k7.mavetju>
 References: <200208230950.g7N9oXDs000777@terrorfish.uni.stoert.net> <20030520074754.GA95715@i2.informatik.rwth-aachen.de>
 
  On Tue, May 20, 2003 at 09:47:54AM +0200, Volker Stolz wrote:
  > On Fri, Aug 23, 2002 at 11:50:33AM +0200, Simon 'corecode' Schubert wrote:
  > > >Description:
  > > 	when including both <string.h> and <machine/cpufunc.h> from a C++
  > > 	source, gcc yields a declaration error:
  > > 
  > > From: Edwin Groothuis <edwin@mavetju.org>
  > >  I ran into the same problem today with ports/audio/mpmf20.
  > >  machine/cpufunc.h does set a flag if it has has been processed:
  > >  HAVE_INLINE_FFS (line 106 of /usr/include/machine/cpufunc.h).
  > >  
  > >  So strings.h could be modified  [...]
  > 
  > I've just been bit by another instance of this (hpoj-printer driver
  > port). Are there any intentions to fix this RSN? Is there somebody
  > specific who could be contacted about this issue?
  > I'm cc:ing mike@ who last touched strings.h.
  
  I've asked tjr@ to do something with it but he didn't come further
  than "well if you swap the two functions you have the same problem
  again"...
  
  Edwin
  

From: Ceri Davies <ceri@FreeBSD.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Sun, 25 May 2003 18:56:05 +0100

 Adding to audit trail, from misfiled PR i386/52474:
 
 Date: Tue, 20 May 2003 09:30:32 -0400
 From: Mike Barcroft <mike@FreeBSD.org>
 Message-Id: <20030520093032.C84644@espresso.bsdmike.org>
 References: <200208230950.g7N9oXDs000777@terrorfish.uni.stoert.net> <20030520074754.GA95715@i2.informatik.rwth-aachen.de>
 
  [Added BDE to CC list.]
  
  Volker Stolz <stolz@i2.informatik.rwth-aachen.de> writes:
  > On Fri, Aug 23, 2002 at 11:50:33AM +0200, Simon 'corecode' Schubert wrote:
  > > >Description:
  > > 	when including both <string.h> and <machine/cpufunc.h> from a C++
  > > 	source, gcc yields a declaration error:
  > > 
  > > From: Edwin Groothuis <edwin@mavetju.org>
  > >  I ran into the same problem today with ports/audio/mpmf20.
  > >  machine/cpufunc.h does set a flag if it has has been processed:
  > >  HAVE_INLINE_FFS (line 106 of /usr/include/machine/cpufunc.h).
  > >  
  > >  So strings.h could be modified  [...]
  > 
  > I've just been bit by another instance of this (hpoj-printer driver
  > port). Are there any intentions to fix this RSN? Is there somebody
  > specific who could be contacted about this issue?
  > I'm cc:ing mike@ who last touched strings.h.
  
  IIRC, the conclusion last time this was brought up was that
  <machine/cpufunc.h> is an implementation detail and should never be
  used by anything except the implementation.
  
  Best regards,
  Mike Barcroft
 

From: Steve Roome <stephen_roome@pepcross.com>
To: freebsd-gnats-submit@FreeBSD.org, corecode@corecode.ath.cx
Cc:  
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Thu, 31 Jul 2003 23:48:08 +0100

 Just noticed that on 4.8-STABLE I get a similar effect compiling code
 with -ansi. Which is similar, possibly slightly different, but adds
 weight for the argument for fixing the ffs() code.
 
 - Example Code ---------------------------------------------------------
 
 #include <string.h>
 #include <machine/console.h>
 #include <vgl.h>
 int main() { return 1; }
 
 - Example Compiler Output ----------------------------------------------
 
 gcc -ansi -Wall -Werror test.c
 cc1: warnings being treated as errors
 In file included from /usr/include/vgl.h:37,
                  from test.c:3:
 /usr/include/machine/cpufunc.h:118: warning: static declaration for `ffs' follows non-static
 
 - End Example ----------------------------------------------------------
 
 This "implementation detail" might be used by a programmer using C++
 or -ansi on a C program, surely it should work ?
 
 [ The code quality rant is left as an exersize for the reader! ]
 
 
         Steve Roome

From: Bruce Evans <bde@zeta.org.au>
To: Steve Roome <stephen_roome@pepcross.com>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Sat, 2 Aug 2003 00:57:36 +1000 (EST)

 On Thu, 31 Jul 2003, Steve Roome wrote:
 
 >  Just noticed that on 4.8-STABLE I get a similar effect compiling code
 >  with -ansi. Which is similar, possibly slightly different, but adds
 >  weight for the argument for fixing the ffs() code.
 >
 >  - Example Code ---------------------------------------------------------
 >
 >  #include <string.h>
 >  #include <machine/console.h>
 >  #include <vgl.h>
 >  int main() { return 1; }
 >
 >  - Example Compiler Output ----------------------------------------------
 >
 >  gcc -ansi -Wall -Werror test.c
 >  cc1: warnings being treated as errors
 >  In file included from /usr/include/vgl.h:37,
 >                   from test.c:3:
 >  /usr/include/machine/cpufunc.h:118: warning: static declaration for `ffs' follows non-static
 >
 >  - End Example ----------------------------------------------------------
 
 This is from namespace pollution in <vgl.h> (it includes the kernel-only
 implementation-detail header <machine/cpufunc.h> and some standard headers).
 
 >  This "implementation detail" might be used by a programmer using C++
 >  or -ansi on a C program, surely it should work ?
 
 Only if the implementation exports its detail.  The implementation shouldn't
 do this gratuitously as in <vgl.h>.
 
 Bruce

From: Marco Molteni <molter@tin.it>
To: freebsd-gnats-submit@FreeBSD.org, corecode@corecode.ath.cx
Cc: Edwin Groothuis <edwin@mavetju.org>,
	Volker Stolz <stolz@i2.informatik.rwth-aachen.de>,
	Mike Barcroft <mike@FreeBSD.org>,
	Steve Roome <stephen_roome@pepcross.com>,
	Bruce Evans <bde@zeta.org.au>
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Tue, 30 Mar 2004 21:44:55 +0200

 (CCing all the people involved)
 
 Please have a look at 
 for a quick, effective, per-port workaround.
 
 Marco

From: Marco Molteni <molter@tin.it>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: i386/41930: declaration clash for ffs() and ${CXX}
Date: Tue, 30 Mar 2004 21:58:50 +0200

 Sorry, the pr I wanted to refer to in my previous mail
 is ports/64945
 
State-Changed-From-To: open->closed  
State-Changed-By: brucec 
State-Changed-When: Sat Mar 28 23:19:08 UTC 2009 
State-Changed-Why:  
This was fixed in rev 1.139 of src/sys/i386/include/cpufunc.h 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41930 
>Unformatted:
