changeset 12500:e6877b45f4e6

New module 'unused-parameter'.
author Bruno Haible <bruno@clisp.org>
date Fri, 25 Dec 2009 02:43:41 +0100
parents 9deb67d8d0d7
children 747078ee6551
files ChangeLog build-aux/unused-parameter.h lib/unistr.h modules/unistr/base modules/unused-parameter
diffstat 5 files changed, 94 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-24  Bruno Haible  <bruno@clisp.org>
+
+	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  <bruno@clisp.org>
 
 	Add missing dependencies to 'extensions' module.
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 <http://www.gnu.org/licenses/>.  */
+
+/* _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
--- 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 <stdbool.h>
 
@@ -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;
 
--- a/modules/unistr/base
+++ b/modules/unistr/base
@@ -6,6 +6,7 @@
 
 Depends-on:
 unitypes
+unused-parameter
 stdbool
 inline
 
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