sardemff7 / libgwater

A collection of GSources
16 stars 4 forks source link

Compilation fails when compiling with -Wunused #3

Closed Hjdskes closed 8 years ago

Hjdskes commented 8 years ago

Hello,

I just came across this awesome library and am converting two projects (gvolicon and mpd-notify) to use it. However, both projects are compiled with extra warnings and errors enabled. The build then fails on unused variables (in this case in alsa-mixer, I have not checked the other files):

  CC       libgwater/alsa-mixer/libgwater_libgwater_alsa_mixer_la-libgwater-alsa-mixer.lo
libgwater/alsa-mixer/libgwater-alsa-mixer.c: In function ‘_g_water_alsa_mixer_source_prepare’:
libgwater/alsa-mixer/libgwater-alsa-mixer.c:52:45: error: unused parameter ‘source’ [-Werror=unused-parameter]
 _g_water_alsa_mixer_source_prepare(GSource *source, gint *timeout)
                                             ^~~~~~
libgwater/alsa-mixer/libgwater-alsa-mixer.c: In function ‘_g_water_alsa_mixer_source_dispatch’:
libgwater/alsa-mixer/libgwater-alsa-mixer.c:72:66: error: unused parameter ‘callback’ [-Werror=unused-parameter]
 _g_water_alsa_mixer_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
                                                                  ^~~~~~~~
libgwater/alsa-mixer/libgwater-alsa-mixer.c:72:85: error: unused parameter ‘user_data’ [-Werror=unused-parameter]
 _g_water_alsa_mixer_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
                                                                                     ^~~~~~~~~
libgwater/alsa-mixer/libgwater-alsa-mixer.c: In function ‘g_water_alsa_mixer_source_new_for_mixer’:
libgwater/alsa-mixer/libgwater-alsa-mixer.c:133:150: error: unused parameter ‘destroy_func’ [-Werror=unused-parameter]
 xt *context, snd_mixer_t *mixer, snd_mixer_callback_t callback, gpointer user_data, GDestroyNotify destroy_func)
                                                                                                    ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:524: libgwater/alsa-mixer/libgwater_libgwater_alsa_mixer_la-libgwater-alsa-mixer.lo] Error 1

Is there something we can do about this? Preferably in libgwater, so that everyone benefits. I am willing to do the work if you give me a pointer on how best to do it.

Thanks!

sardemff7 commented 8 years ago

As GLib is heavily based on callbacks, with many many of them using user_data, but not always useful, I tend to add -Wno-unused-parameter to all my (GLib-based) projects. And I consider -Werror a bad idea (because way too many projects just add it unconditionally which breaks as soon as you update your compiler, bringing new unexpected warnings).

Anyway, I pushed e1f98d377f2b1dbeab224e48e9c55b7be99a9e14, please test.

Hjdskes commented 8 years ago

Sorry for the late reply. Everything works perfectly, thanks you!