[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stdlib tweak
From: |
Jim Meyering |
Subject: |
Re: stdlib tweak |
Date: |
Wed, 23 Dec 2009 15:08:13 +0100 |
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.
- Re: ASSERT and _GL_UNUSED macros, (continued)
- Re: ASSERT and _GL_UNUSED macros, Eric Blake, 2009/12/23
- Re: ASSERT macro, Bruno Haible, 2009/12/23
- Re: _GL_UNUSED macro, Bruno Haible, 2009/12/23
- new module 'unused-parameter', Bruno Haible, 2009/12/24
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/25
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/27
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/29
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/29
- Re: stdlib tweak,
Jim Meyering <=
- Re: stdlib tweak, Bruno Haible, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Bruno Haible, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Eric Blake, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Eric Blake, 2009/12/24
- Re: ASSERT and SIGNATURE_CHECK macros, Jim Meyering, 2009/12/24
- Re: SIGNATURE_CHECK, Bruno Haible, 2009/12/24
- Re: SIGNATURE_CHECK, Eric Blake, 2009/12/24
- Re: SIGNATURE_CHECK, Bruno Haible, 2009/12/24