[vlc-devel] [PATCH 7/8] vlc_plugin.h: Cast the deactivate function pointer
Romain Vimont
rom1v at videolabs.io
Thu Dec 3 18:03:43 CET 2020
On Thu, Dec 03, 2020 at 06:39:47PM +0200, Rémi Denis-Courmont wrote:
> Le torstaina 3. joulukuuta 2020, 17.16.20 EET Hugo Beauzée-Luyssen a écrit :
> > Instead of initializing a function pointer using a compound literal,
> > which might not compile in C++
> > ---
> > include/vlc_plugin.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
> > index 63f0b3ac08..7a68c953e3 100644
> > --- a/include/vlc_plugin.h
> > +++ b/include/vlc_plugin.h
> > @@ -313,7 +313,7 @@ VLC_METADATA_EXPORTS
> > #define set_callbacks( activate, deactivate ) \
> > set_callback(activate) \
> > if (vlc_module_set(VLC_MODULE_CB_CLOSE, #deactivate, \
> > - (void (*)(vlc_object_t *)){ deactivate })) \
> > + (void (*)(vlc_object_t *))( deactivate ))) \
>
> The current code will warn if the conversion makes no sense.
> This won't.
It seems this does warn. For example, if we cast to a wrong function type
instead:
if (vlc_module_set(VLC_MODULE_CB_CLOSE, #deactivate, \
(void (*)(int))( deactivate ))) \
../../include/vlc_plugin.h:316:24: warning: cast between incompatible function types from ‘void (*)(vlc_object_t *)’ to ‘void (*)(int)’ [-Wcast-function-type]
316 | (void (*)(int))( deactivate ))) \
More information about the vlc-devel
mailing list