ATF-devel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: -Werror=unused-but-set-variable

On 8/10/11 5:22 PM, Emmanuel Fleury wrote:
> Hi,

Hello Emmanuel,

> I'm hitting a build error when trying to compile atf with gcc 4.6.1.
> $ gcc --version
> gcc (Debian 4.6.1-6) 4.6.1

Unfortunately I don't have access to that gcc version at the moment, but
see below.  (I'll try to get access to one before the next release to
ensure that it will build fine "out of the box".)

> While executing: autoreconf -is && ./configure && make
> I have the following error:
> atf-c/check.c: In function 'atf_check_result_init':
> atf-c/check.c:304:17: error: variable 'workdir' set but not used
> [-Werror=unused-but-set-variable]
> cc1: all warnings being treated as errors
> make[1]: *** [atf-c/libatf_c_la-check.lo] Error 1
> make[1]: Leaving directory `/home/fleury/tmp/atf-dev/src'
> make: *** [all] Error 2
> In my humble opinion, you should add -Wno-unused to the compile flags to
> avoid unused variables/functions/... detection.

-Wunused is the flag to detect all unused items, and -Wall implies
-Wunused.  If you take a look at m4/developer-mode.m4, you'll see that
we are actually passing -Wno-unused-parameter explicitly to disable the
checking of unused parameters.

I inherited the -Wno-unused-parameter from the NetBSD standard set of
strict warning checks and didn't think about it much.

I think your suggestion means getting rid of this flag so that we
actually do check for unused parameters; correct?  It seems to be the
default anyway in gcc 4.6.  I like the idea.

I'm now working on this locally but the change is quite invasive: I have
to add many __attribute__((unused)) attributes to the code because some
unused parameters are legitimate.  That said, there are many unused
parameters that can be removed :-)

In the meantime, if you do 'configure --disable-developer' you will
disable all strict warning checks and you will also disable -Werror,
which should let you build the code successfully by ignoring any
warnings that arise.

> For now I didn't manage to add the additional flags to the build-system.
> It seems that using the ATF_BUILD_CFLAGS (and ATF_BUILD_CXXFLAGS) is not
> enough.

These variables (ATF_BUILD_*) are used to tune the built-in compiler
settings that atf will later expose to tests that use the atf_build_*
functions (see atf-c/build.h).  They do not configure how atf itself is

To tune the flags passed to the compilation of ATF, use the standard
CFLAGS and CXXFLAGS variables.

The INSTALL document should be describing all this.  If it feels
confusing or incomplete, let me know.

Lastly, let me know if the above helps and thanks for your report!


Julio Merino / @jmmv

Home | Main Index | Thread Index | Old Index