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

Steve Lhomme robux4 at gmail.com
Thu Sep 15 08:31:08 CEST 2016


On Wed, Sep 14, 2016 at 6:35 PM, Hugo Beauzée-Luyssen <hugo at beauzee.fr> wrote:
> On 09/14/2016 06:32 PM, Rémi Denis-Courmont wrote:
>>
>> 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.
>>
>
> I'd favor the const-preserving version, but I might miss a bit of background
> when it comes to vlc_obejct's...

Maybe a VLC_CONST_OBJECT is needed ?

> Regards,
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list