Jim Meyering wrote: > However, it would be good to accept patches (at least for gnulib's .h > files) that mark each unused parameter with __attribute__ ((__unused__)). > Then, a project that requires use of -Wunused-parameter can use gnulib's > headers without having to relax their standards.
I agree regarding gnulib's public .h files. I'll handle unistr.h. > although I admit to disliking the seemingly necessary duplication of > the snippet to define __attribute__. One could define __attribute__, or a special-purpose macro, in an extra module. But then keeping track of the module dependency is some work. It's easier to define it in generated config.h always. I propose this. A special-purpose macro called _UNUSED_PARAMETER_ is as understandable as is __attribute__ ((__unused__)), and may accomodate other compilers (whereas #defining __attribute__ is gcc specific). gcc 2.7.2.3 already supported __attribute__ ((__unused__)), as far as I can see. 2008-10-18 Bruno Haible <[EMAIL PROTECTED]> Avoid -Wunused-parameter warnings in public gnulib header files. * m4/gnulib-common.m4 (gl_COMMON_BODY): Define _UNUSED_PARAMETER_ as a macro. * lib/unistr.h (u32_mbtouc_unsafe, u32_mbtouc): Use it. --- m4/gnulib-common.m4.orig 2008-10-18 20:28:22.000000000 +0200 +++ m4/gnulib-common.m4 2008-10-18 19:59:26.000000000 +0200 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 5 +# gnulib-common.m4 serial 6 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -21,6 +21,16 @@ #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ # define __GNUC_STDC_INLINE__ 1 #endif]) + AH_VERBATIM([unused_parameter], +[/* Define as a marker that can be attached to function parameter declarations + for parameters that are not used. This helps to reduce warnings, such as + from GCC -Wunused-parameter. */ +#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _UNUSED_PARAMETER_ __attribute__ ((__unused__)) +#else +# define _UNUSED_PARAMETER_ +#endif +]) ]) # gl_MODULE_INDICATOR([modulename]) --- lib/unistr.h.orig 2008-10-18 20:28:22.000000000 +0200 +++ lib/unistr.h 2008-10-18 20:27:39.000000000 +0200 @@ -1,5 +1,5 @@ /* Elementary Unicode string functions. - Copyright (C) 2001-2002, 2005-2007 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2005-2008 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -183,7 +183,7 @@ u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int -u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n) +u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n _UNUSED_PARAMETER_) { uint32_t c = *s; @@ -253,7 +253,7 @@ u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n); # else static inline int -u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n) +u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _UNUSED_PARAMETER_) { uint32_t c = *s;