warn-on-use: new module
authorEric Blake <ebb9@byu.net>
Wed, 16 Dec 2009 21:53:06 +0000 (14:53 -0700)
committerEric Blake <ebb9@byu.net>
Mon, 11 Jan 2010 13:49:48 +0000 (06:49 -0700)
commit039dc49e7e584131dc304bfb99b6e52812092827
tree94e3b8fbf6c478f1ab9f9814c558c3a8e826ec01
parentbe4eb87a42019da6130d0840fcb6b691628f2f2a
warn-on-use: new module

The goal of GNULIB_POSIXCHECK is to allow a developer on a reasonably
portable system to detect instances where they may have succeeded
because their system is up-to-date, but where compilation would fail
or create a misbehaving application on some other system due to some
portability problem, all without requiring that the developer have
access to other machines.  In other words, we want to poison all
interfaces that have a gnulib replacement if the corresponding gnulib
module is not in use.  For macros, the solution is undefining the
macro; unfortunately this causes compilation error without many
details as to why, but it is better than nothing.  For functions, the
solution is to cause a warning if the function is used.

Previously, the link-warning could poison functions, but only on glibc
systems and with gcc.  This module introduces _GL_WARN_ON_USE as a way
of poisoning functions for a few more systems.

Using the gcc __warning__ attribute (added in 4.3.0, early 2008)
rather than using link-warning.h is favorable because:
1) Provides a warning immediately at compile-time. The user does not
   have to wait until he links a program.
2) Less use of C macros. Less risk of collision.
3) It's available on more platforms. Depends only on GCC.
4) The formatting of the message is nicer.

There is a minor regression: the gcc attribute is currently not as
powerful as a link warning at detecting uses via function pointers:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42384
However, that style of coding is less frequent.

* modules/warn-on-use: New file.
* build-aux/warn-on-use.h: Likewise.
* m4/warn-on-use.m4: Likewise.
* MODULES.html.sh (Support for building): Mention it.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
MODULES.html.sh
build-aux/warn-on-use.h [new file with mode: 0644]
m4/warn-on-use.m4 [new file with mode: 0644]
modules/warn-on-use [new file with mode: 0644]