This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RFC: should we use -Werror? (& sample patch to do it)

On Fri, Sep 07, 2001 at 09:39:38PM -0400, Kaveh R. Ghazi wrote:
>  > From: Zack Weinberg <>
>  > 
>  > (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


>  > .-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 and/or 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.


[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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]