[vlc-devel] [PATCH] vlc_common.h: Fix VLC_OBJECT when building with clang

Rémi Denis-Courmont remi at remlab.net
Wed Sep 14 18:32:20 CEST 2016


Le keskiviikkona 14. syyskuuta 2016, 18.26.18 EEST Hugo Beauzée-Luyssen a 
écrit :
> On 09/14/2016 06:25 PM, Rémi Denis-Courmont wrote:
> > Le keskiviikkona 14. syyskuuta 2016, 18.10.31 EEST Hugo Beauzée-Luyssen a
> > 
> > écrit :
> >> ---
> >> 
> >>  include/vlc_common.h | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/include/vlc_common.h b/include/vlc_common.h
> >> index 5a6bf19..59988fa 100644
> >> --- a/include/vlc_common.h
> >> +++ b/include/vlc_common.h
> >> @@ -476,7 +476,8 @@ struct vlc_common_members
> >> 
> >>  #if !defined(__cplusplus) && (__STDC_VERSION__ >= 201112L)
> >>  # define VLC_OBJECT(x) \
> >>  
> >>      _Generic((x)->obj, \
> >> 
> >> -        struct vlc_common_members: (vlc_object_t *)(&(x)->obj) \
> >> +        struct vlc_common_members: (vlc_object_t *)(&(x)->obj), \
> >> +        const struct vlc_common_members: (const vlc_object_t
> >> *)(&(x)->obj)
> >> \ )
> >> 
> >>  #elif VLC_GCC_VERSION(4,0)
> >>  # ifndef __cplusplus
> > 
> > That´s not right. VLC_OBJECT() expects a pointer to non-constant. We do
> > want to warn or fail otherwise.
> 
> In that case we might want to fix vlc_object_get_name's prototype

It might actually be simpler to just redefine VLC_OBJECT() to preserve 
constness, and merge this patch anyway.

In previous versions, it just discarded the const qualifier, which was not so 
great.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list