Bruno Haible wrote: >> Considering that this will appear in nearly every .c file in gnulib/lib, > > You mean, in gnulib/tests/, I guess?
Yes. >> Then, each use would be more concise: >> >> GL_SIG_CHECK (atexit, int, (void (*) (void))); > > I like the idea: it provides an abstraction over this arcane C function > pointer > syntax. > >> how about a macro to encapsulate whatever idiom we use? >> Even if it means emitting that into config.h. > > Since it's a utility macro only for the tests, I would much prefer to have it > in a file such as tests/macros.h, rather than polluting config.h with stuff > that exists only for the tests. This file tests/macros.h could also contain > the ubiquitous ASSERT macro. (I try to keep the tests as transparent and > will as little boilerplate complexity as possible. But a macro that is used > more than 200 times can certainly be refactored.) That would be welcome ;-) >> #define GL_SIG_CHECK(fn, ret_type, param_list) \ >> static ret_type (* _UNUSED_PARAMETER_ signature_check) param_list = fn > > In order to allow multiple uses of this macro in the same file, it should > probably use __LINE__. Also better call it CHECK_SIGNATURE: 'SIG' reminds > me too much of 'signal', and the prefix "GL_" is unneeded here. > >> Otherwise we'd unnecessarily pollute the linker name space. All valid points, once I realized the target was /tests/*.c, not lib/*.c. >> > It also means that the gnulib guarantee that _UNUSED_PARAMETER_ >> > expands to __attribute__((__unused__)) is a bit of a misnomer, as in this >> > case, >> > signature_check is not a parameter. Do we want to introduce a new alias, >> > _GL_UNUSED, and use that instead of _UNUSED_PARAMETER_? (Unfortunately, we >> >> I would prefer _GL_UNUSED, too. >> Not only a shorter name, but also more apt. >> If you want to deprecate _UNUSED_PARAMETER_ outside of gnulib, > > I would leave _UNUSED_PARAMETER_ as it is. It is well named and frequently > used. You are now trying to use __attribute__((__unused__)) also for a > different case; that does not mean that _UNUSED_PARAMETER_ needs to be > changed. Since Eric seems likely to introduce only one new use, its actual name matters far less.