# HG changeset patch # User Bruno Haible # Date 1261705421 -3600 # Node ID e6877b45f4e6cf842d48726ec1f670a1e5d397e0 # Parent 9deb67d8d0d7e86b7ddd8784b2ab02d719c25931 New module 'unused-parameter'. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-12-24 Bruno Haible + + New module 'unused-parameter'. + * build-aux/unused-parameter.h: New file, extracted from earlier + gnulib-common.m4. + * modules/unused-parameter: New file. + * lib/unistr.h: Include unused-parameter.h. + (u32_mbtouc_unsafe, u32_mbtouc): Use _GL_UNUSED_PARAMETER instead of + _GL_UNUSED. + * modules/unistr/base (Depends-on): Add unused-parameter. + 2009-12-24 Bruno Haible Add missing dependencies to 'extensions' module. diff --git a/build-aux/unused-parameter.h b/build-aux/unused-parameter.h new file mode 100644 --- /dev/null +++ b/build-aux/unused-parameter.h @@ -0,0 +1,36 @@ +/* A C macro for declaring that specific function parameters are not used. + Copyright (C) 2008-2009 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 + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +/* _GL_UNUSED_PARAMETER is a marker that can be appended to function parameter + declarations for parameters that are not used. This helps to reduce + warnings, such as from GCC -Wunused-parameter. The syntax is as follows: + type param _GL_UNUSED_PARAMETER + or more generally + param_decl _GL_UNUSED_PARAMETER + For example: + int param _GL_UNUSED_PARAMETER + int *(*param)(void) _GL_UNUSED_PARAMETER + Other possible, but obscure and discouraged syntaxes: + int _GL_UNUSED_PARAMETER *(*param)(void) + _GL_UNUSED_PARAMETER int *(*param)(void) + */ +#ifndef _GL_UNUSED_PARAMETER +# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__)) +# else +# define _GL_UNUSED_PARAMETER +# endif +#endif diff --git a/lib/unistr.h b/lib/unistr.h --- a/lib/unistr.h +++ b/lib/unistr.h @@ -19,6 +19,9 @@ #include "unitypes.h" +/* Get common macros for C. */ +#include "unused-parameter.h" + /* Get bool. */ #include @@ -183,7 +186,8 @@ 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 _GL_UNUSED) +u32_mbtouc_unsafe (ucs4_t *puc, + const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; @@ -253,7 +257,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 _GL_UNUSED) +u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER) { uint32_t c = *s; diff --git a/modules/unistr/base b/modules/unistr/base --- a/modules/unistr/base +++ b/modules/unistr/base @@ -6,6 +6,7 @@ Depends-on: unitypes +unused-parameter stdbool inline diff --git a/modules/unused-parameter b/modules/unused-parameter new file mode 100644 --- /dev/null +++ b/modules/unused-parameter @@ -0,0 +1,40 @@ +Description: +A C macro for declaring that specific function parameters are not used. + +Applicability: +all + +Files: +build-aux/unused-parameter.h + +Depends-on: + +configure.ac: + +Makefile.am: +# The BUILT_SOURCES created by this Makefile snippet are not used via #include +# statements but through direct file reference. Therefore this snippet must be +# present in all Makefile.am that need it. This is ensured by the applicability +# 'all' defined above. + +BUILT_SOURCES += unused-parameter.h +# The unused-parameter.h that gets inserted into generated .h files is the same +# as build-aux/unused-parameter.h, except that it has the copyright header cut +# off. +unused-parameter.h: $(top_srcdir)/build-aux/unused-parameter.h + $(AM_V_GEN)rm -f $@-t $@ && \ + sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \ + < $(top_srcdir)/build-aux/unused-parameter.h \ + > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t + +UNUSED_PARAMETER_H=unused-parameter.h + +Include: + +License: +LGPLv2+ + +Maintainer: +Bruno Haible