bug-gnulib
[Top][All Lists]
Advanced

[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 11:44:15 +0100

Eric Blake wrote:
> Jim Meyering <jim <at> meyering.net> writes:
>
>> > +int (*signature_check) (void (*) (void)) = atexit;
>>
>> I haven't looked carefully at each or tested, but...
>> please use the "static" attribute on all of those,
>> as in your example above.
>
> I thought about that, but with:
>
> +static int (*signature_check) (void (*) (void)) = atexit;
>
> you then get:
>
>   CC       test-atexit.o
> test-atexit.c:23: warning: ‘signature_check’ defined but not used [-Wunused-
> variable]

I realized that minutes after posting.

> So, to avoid the warning, it would have to be:
>
> +static int (* _UNUSED_PARAMETER_ signature_check) (void (*) (void)) = atexit;

Considering that this will appear in nearly every .c file in gnulib/lib,
how about a macro to encapsulate whatever idiom we use?
Even if it means emitting that into config.h.

    #define GL_SIG_CHECK(fn, ret_type, param_list) \
      static ret_type (* _UNUSED_PARAMETER_ signature_check) param_list = fn

Then, each use would be more concise:

    GL_SIG_CHECK (atexit, int, (void (*) (void)));

and the implementation would be far easier to adjust, if needed.

> I can do that, but it is a bit more work, so please confirm if you'd
> like to see that.

I think we have no choice.
Otherwise we'd unnecessarily pollute the linker name space.

> 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,
add a syntax-check rule for it ;-)

> have to keep the _UNUSED_PARAMETER_ name around a bit longer - it has crept
> into use in other projects that assume that it is available merely because
> they are using gnulib).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]