[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new module 'unused-parameter'
From: |
Bruno Haible |
Subject: |
new module 'unused-parameter' |
Date: |
Fri, 25 Dec 2009 02:43:29 +0100 |
User-agent: |
KMail/1.9.9 |
Eric Blake wrote:
> > Therefore my proposal is to
> > - create a new module 'unused-parameter', that inserts a definition of
> > _GL_UNUSED_PARAMETER_ in a header file, like 'link-warning' and 'arg-
> nonnull'
> > do,
> > - update unistr.h accordingly.
>
> Sounds reasonable. But I'd rather see _GL_UNUSED_PARAMETER than
> _GL_UNUSED_PARAMETER_
This implements the module, and makes unistr.h work again for libunistring.
2009-12-24 Bruno Haible <address@hidden>
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.
======================== build-aux/unused-parameter.h ========================
/* 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
========================== modules/unused-parameter ==========================
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 address@hidden $@ && \
sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
< $(top_srcdir)/build-aux/unused-parameter.h \
> address@hidden && \
mv address@hidden $@
MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
UNUSED_PARAMETER_H=unused-parameter.h
Include:
License:
LGPLv2+
Maintainer:
Bruno Haible
==============================================================================
--- lib/unistr.h.orig Fri Dec 25 02:40:04 2009
+++ lib/unistr.h Fri Dec 25 02:07:02 2009
@@ -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;
--- modules/unistr/base.orig Fri Dec 25 02:40:04 2009
+++ modules/unistr/base Fri Dec 25 01:48:44 2009
@@ -6,6 +6,7 @@
Depends-on:
unitypes
+unused-parameter
stdbool
inline
- Re: stdlib tweak, (continued)
- Re: stdlib tweak, Eric Blake, 2009/12/22
- Re: stdlib tweak, Jim Meyering, 2009/12/22
- Re: stdlib tweak, Eric Blake, 2009/12/22
- Re: stdlib tweak, Jim Meyering, 2009/12/23
- Re: stdlib tweak, Bruno Haible, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: ASSERT and _GL_UNUSED macros, Bruno Haible, 2009/12/23
- Re: ASSERT and _GL_UNUSED macros, Eric Blake, 2009/12/23
- Re: ASSERT macro, Bruno Haible, 2009/12/23
- Re: _GL_UNUSED macro, Bruno Haible, 2009/12/23
- new module 'unused-parameter',
Bruno Haible <=
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/25
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/27
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/29
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/29
- Re: stdlib tweak, Jim Meyering, 2009/12/23
- Re: stdlib tweak, Bruno Haible, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23