From owner-freebsd-current@FreeBSD.ORG Tue Aug 2 05:42:01 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 0D12E16A41F for ; Tue, 2 Aug 2005 05:42:01 +0000 (GMT) (envelope-from rodrigc@crodrigues.org) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98DF143D46 for ; Tue, 2 Aug 2005 05:42:00 +0000 (GMT) (envelope-from rodrigc@crodrigues.org) Received: from c-66-30-114-143.hsd1.ma.comcast.net (c-66-30-115-133.hsd1.ma.comcast.net[66.30.115.133](misconfigured sender)) by comcast.net (sccrmhc11) with ESMTP id <2005080205400701100huslge>; Tue, 2 Aug 2005 05:40:07 +0000 Received: from c-24-63-58-5.hsd1.ma.comcast.net (localhost.127.in-addr.arpa [127.0.0.1]) by c-66-30-114-143.hsd1.ma.comcast.net (8.13.4/8.13.1) with ESMTP id j725eC75072729 for ; Tue, 2 Aug 2005 01:40:12 -0400 (EDT) (envelope-from rodrigc@c-24-63-58-5.hsd1.ma.comcast.net) Received: (from rodrigc@localhost) by c-24-63-58-5.hsd1.ma.comcast.net (8.13.4/8.13.1/Submit) id j725eCXx072728 for freebsd-current@freebsd.org; Tue, 2 Aug 2005 01:40:12 -0400 (EDT) (envelope-from rodrigc) Date: Tue, 2 Aug 2005 01:40:12 -0400 From: Craig Rodrigues To: freebsd-current@freebsd.org Message-ID: <20050802054012.GA72632@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Subject: Why -Wredundant-decls in sys/conf/kern.mk? 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: Tue, 02 Aug 2005 05:42:01 -0000 Hi, I am looking into getting the kernel to compile with gcc 4.0, and encountered something which I am not sure about. In sys/conf/kern.mk, why do we have -Wredundant-decls in the CWARNFLAGS: CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \ I have no problems with the other warning flags. However -Wredundant-decls warns for: `-Wredundant-decls' Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. This warning causes gcc to emit a warning for legal C code, that normally not even -Wall would complain about. For example, gcc compiles this code compiles fine, even with -Wall: struct a { }; static struct a b; static struct a b = { }; but emits a warning with -Wredundant-decls: r.c:1: warning: redundant redeclaration of 'b' r.c:1: warning: previous declaration of 'b' was here There are places in the kernel that want to forward declare a struct as static, and then implement it later on. Since it is legal in C to do this, are we gaining anything by having this flag in the kernel's CWARNFLAGS? Does -Wredundant-decls warn against other things that are useful to warn against? Sorry if this is a silly question....I'm not a C expert. Thanks. -- Craig Rodrigues rodrigc@crodrigues.org