bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unused parameter warnings


From: Jeffrey Walton
Subject: Re: Unused parameter warnings
Date: Sun, 11 Oct 2020 22:21:58 -0400

On Sun, Oct 11, 2020 at 7:11 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> > -static size_t
> > +static size_t _GL_ATTRIBUTE_PURE
> >  gl_tree_size (gl_list_t list)
>
> Although changes like these don't break anything, I generally don't bother 
> doing
> them if only older GCCs warn about a missing attribute, under the theory that
> people stuck with older compilers can build with --disable-gcc-warnings and it
> lessens the maintenance burden if we don't bloat the code with obvious detail
> that a decent compiler should deduce automatically.

For this particular warning, I find it is easier to forgo the compiler
specific attributes and then use an UNUSED macro. The UNUSED macro
works everywhere with all compilers. It also does not pollute the
function signature.

    #ifndef GNULIB_UNUSED
    # define GNULIB_UNUSED(x) ((void)(x))
    #endif

And then:

    const char*
    gl_locale_name_thread_unsafe (int category, const char *categoryname)
    {
        GNULIB_UNUSED(category);
        ...
    }

Jeff



reply via email to

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