13.18 warnings

The warnings module allows to regularly build a package with more
GCC warnings than the default warnings emitted by GCC.

It provides the following functionality:

You can select some warning options, such as ‘-Wall’, to be enabled
whenever building with a GCC version that supports these options. The
user can choose to override these warning options by providing the
opposite options in the CFLAGS variable at configuration time.

You can make these warnings apply to selected directories only. In
projects where subprojects are maintained by different people, or where
parts of the source code are imported from external sources (for example
from gnulib), it is useful to apply different warning options to
different directories.

It lets you use ‘-Werror’ at ‘make distcheck’ time, to verify
that on the maintainer’s system, no warnings remain. (Note that use of
‘-Werror’ in CFLAGS does not work in general, because it may
break autoconfiguration.)

Similarly, it lets you use ‘-Werror’ when the builder runs
configure with an option such as
--enable-gcc-warnings.

In the directories which shall use WARN_CFLAGS, use it in the
definition of AM_CFLAGS, like this:

AM_CFLAGS = $(WARN_CFLAGS)

Note that the AM_CFLAGS is used in combination with CFLAGS
and before CFLAGS in build rules emitted by Automake. This allows
the user to provide CFLAGS that override the WARN_CFLAGS.

‘gl_WARN_ADD([-Werror])’ is intended for developers, and should be
avoided in contexts where it would affect ordinary installation builds. The
warnings emitted by GCC depend, to some extent, on the contents of the
system header files, on the size and signedness of built-in types, etc.
Use of ‘-Werror’ would cause frustration to all users on platforms
that the maintainer has not tested before the release. It is better if
‘-Werror’ is off by default, and is enabled only by developers.
For example, ‘-Werror’ could affect ‘make distcheck’ or
‘configure --enable-gcc-warnings’ as mentioned above.