RFC: should we use -Werror? (& sample patch to do it)
Zack Weinberg
zack@codesourcery.com
Fri Sep 7 19:49:00 GMT 2001
On Fri, Sep 07, 2001 at 09:39:38PM -0400, Kaveh R. Ghazi wrote:
> > From: Zack Weinberg <zack@codesourcery.com>
> >
> > (There are cleaner ways to do the same thing, e.g. look at the hack
> > used to avoid -pedantic for the non-C front ends.)
> > zw
>
> I suppose you're referring to the following from Makefile.in?
Yes.
> > .-warn = $(STRICT_WARN)
> > GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn)
>
> I can't figure this out, can you please explain it? How does it work?
$(@D) expands to the directory containing the current target
_as it is referred to in the Makefile_. If the current target is
"toplev.o", $(@D) is ".". If the current target is "java/parse.o",
$(@D) is "java".
When you write a variable reference inside a variable reference, (all
modern versions of) Make expand the inner reference first and mash the
result into the variable name to be looked up by the outer reference.
Therefore, $($(@D)-warn) is equivalent to $(.-warn) for toplev.o,
$(java-warn) for java/parse.o, etc. We set .-warn to $(STRICT_WARN)
and java-warn etc. to empty, we get $(STRICT_WARN) added to
GCC_WARN_CFLAGS for the top level only.[1]
So, how'd you use this for -Werror? Like this:
GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $($@-warn)
# These files (and only these) are to have no-warnings enforced.
toplev.o-warn = -Werror
c-common.o-warn = -Werror
cp/parse.o-warn = -Werror
# ...
Each Makefile.in and/or Make-lang.in would have the appropriate list
for the files it controls.
I suppose this could also be used to do
combine.o-warn = -Wno-sign-compare
but that would be cheating.
zw
[1] Make has practically no restrictions on what characters can appear
in a variable name. I think it's just = : $ ( ). You can even have
interior white space.
More information about the Gcc
mailing list