[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: -Werror flag set unconditionally

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta_at_gmail.com>
Date: Thu, 20 Dec 2012 05:08:29 +0100

2012-12-20 04:41:56 Branko Čibej napisał(a):
> On 20.12.2012 04:31, Arfrever Frehtes Taifersar Arahesis wrote:
> > 2012-12-20 03:39:30 Branko Čibej napisał(a):
> >> I found the following in configure.ac which unconditionally adds a
> >> -Werror flag:
> >>
> >> dnl Add -Werror=implicit-function-declaration to CFLAGS
> >> CFLAGS_KEEP="$CFLAGS"
> >> CFLAGS="$CFLAGS_KEEP -Werror=implicit-function-declaration"
> >> AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])], [CFLAGS_KEEP="$CFLAGS"])
> >> CFLAGS="$CFLAGS_KEEP"
> >>
> >>
> >> I'm almost sure this should only be done in maintainer-mode?
> >
> > We want to always use -Werror=implicit-function-declaration (if compiler supports it)
> > to ensure that nobody forgets to include required headers.
>
> I'm not convinced. We add -Wmissing-prototypes in maintainer-mode. Why
> would we act differently in this case?

-Wmissing-prototypes and -Werror=missing-prototypes do NOT detect calls to undeclared functions in C.

$ echo "int main(){some_function();}" > test.c
$ gcc -c test.c
$ gcc -Wimplicit-function-declaration -c test.c
test.c: In function ‘main’:
test.c:1:1: warning: implicit declaration of function ‘some_function’ [-Wimplicit-function-declaration]
$ gcc -Wmissing-prototypes -c test.c
$ gcc -Werror=implicit-function-declaration -c test.c
test.c: In function ‘main’:
test.c:1:1: error: implicit declaration of function ‘some_function’ [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors
$ gcc -Werror=missing-prototypes -c test.c
$ g++ -c test.c
test.c: In function ‘int main()’:
test.c:1:26: error: ‘some_function’ was not declared in this scope
$

-- 
Arfrever Frehtes Taifersar Arahesis

Received on 2012-12-20 05:09:26 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.