From owner-freebsd-current@FreeBSD.ORG Thu May 26 07:28:10 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E571816A41C for ; Thu, 26 May 2005 07:28:10 +0000 (GMT) (envelope-from stefan@fafoe.narf.at) Received: from fafoe.narf.at (chello213047085026.6.14.vie.surfer.at [213.47.85.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 891DE43D1F for ; Thu, 26 May 2005 07:28:10 +0000 (GMT) (envelope-from stefan@fafoe.narf.at) Received: from wombat.fafoe.narf.at (wombat.fafoe.narf.at [192.168.1.42]) by fafoe.narf.at (Postfix) with ESMTP id 164444180; Thu, 26 May 2005 09:28:05 +0200 (CEST) Received: by wombat.fafoe.narf.at (Postfix, from userid 1001) id 2D4EF15D; Thu, 26 May 2005 09:28:03 +0200 (CEST) Date: Thu, 26 May 2005 09:28:02 +0200 From: Stefan Farfeleder To: Craig Rodrigues Message-ID: <20050526072801.GM596@wombat.fafoe.narf.at> Mail-Followup-To: Craig Rodrigues , freebsd-current@freebsd.org References: <20050526020143.GA80396@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050526020143.GA80396@crodrigues.org> User-Agent: Mutt/1.5.9i Cc: freebsd-current@freebsd.org Subject: Re: [GCC 4.0 PATCH] devfs_vnops.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2005 07:28:11 -0000 On Wed, May 25, 2005 at 10:01:43PM -0400, Craig Rodrigues wrote: > Hi, > > When I tried to compile src/sys/fs/devfs/devs_vnops.c > with GCC 4.0, I got the following compilation errors: > > /usr/src/sys/fs/devfs/devfs_vnops.c:1389: error: static declaration of 'devfs_vnodeops' follows non-static declaration > /usr/src/sys/fs/devfs/devfs_vnops.c:114: error: previous declaration of 'devfs_vnodeops' was here > /usr/src/sys/fs/devfs/devfs_vnops.c:1411: error: static declaration of 'devfs_specops' follows non-static declaration > /usr/src/sys/fs/devfs/devfs_vnops.c:115: error: previous declaration of 'devfs_specops' was here > > Apparently, it is not valid C to define something as extern > and then later on static in the same file, like: > > extern struct foo bar; > static struct foo bar = { .... }; Yes. > What do people think of the following patch to fix it? > > http://people.freebsd.org/~rodrigc/devfs_vnops.c.diff.txt Contrary to what Poul-Henning said, in this case it's perfectly legal to use: static struct foo bar; [...] static struct foo bar = { ... }; The first declaration is a tentative definition (it defines the object only if no `real' definition with an initialiser is found), the second declaration defines the object bar. There is only a problem if bar had array type and bar's initialiser was used to define the array size, because then the tentative definition static struct foo bar[]; would be illegal since bar has an incomplete type (6.9.2#3). Stefan