[libdvdnav-devel] [PATCH 1/2] configure.ac: Create an UNUSED #define for parameter passing

Andrew Clayton andrew at digital-domain.net
Tue Nov 4 02:08:31 CET 2014


Some functions in libdvdread take parameters that are unused, e.g
file_read() in dvd_input.c. These functions can't be changed to remove
the unused parameters as they are public API.

GCC provides a __attribute__((unused)) annotation that can be used on
function parameters to inform the compiler of such and will squash
warnings of the following nature

    src/dvd_input.c: In function 'file_read':
    src/dvd_input.c:218:69: warning: unused parameter 'flags'
      [-Wunused-parameter]
     static int file_read(dvd_input_t dev, void *buffer, int blocks,
                          int flags)
                              ^

A check is added to configure.ac for the use of GCC and if found it
creates an UNUSED #define set to __attribute__((unused)) otherwise it
just sets it empty.

If compilers on other systems have a similar feature this check can be
adjusted to accommodate them.

Signed-off-by: Andrew Clayton <andrew at digital-domain.net>
---
 configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index cf0c4e5..9142673 100644
--- a/configure.ac
+++ b/configure.ac
@@ -99,6 +99,12 @@ AS_IF([test "x$DOXYGEN" = "x"], [
 ])
 AM_CONDITIONAL([APIDOC], [test "x$DOXYGEN" != "x" && test "x$enable_apidoc" = "xyes"])
 
+AS_IF([test "x$ac_cv_c_compiler_gnu" = "xyes"], [
+  AC_DEFINE([UNUSED], [__attribute__((unused))], [Unused parameter annotation])
+], [
+  AC_DEFINE([UNUSED], [], [Unused parameter annotation])
+])
+
 dnl ---------------------------------------------
 dnl Output configuration files
 dnl ---------------------------------------------
-- 
1.9.3



More information about the libdvdnav-devel mailing list