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

Andrew Clayton git at videolan.org
Wed Nov 5 11:44:50 CET 2014


libdvdread | branch: master | Andrew Clayton <andrew at digital-domain.net> | Tue Nov  4 01:08:31 2014 +0000| [c10f0f7c909a26b7d3b4953924a6e88285aae19f] | committer: Jean-Baptiste Kempf

configure.ac: Create an UNUSED #define for parameter passing

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>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/libdvdread.git/?a=commit;h=c10f0f7c909a26b7d3b4953924a6e88285aae19f
---

 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 ---------------------------------------------



More information about the libdvdnav-devel mailing list