Date: Tue, 2 Aug 2005 01:40:12 -0400 From: Craig Rodrigues <rodrigc@crodrigues.org> To: freebsd-current@freebsd.org Subject: Why -Wredundant-decls in sys/conf/kern.mk? Message-ID: <20050802054012.GA72632@crodrigues.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050802054012.GA72632>