[vlc-devel] [PATCH] objects: get the vlc_object_t from vlc_object_internals using vlc_internals()

Rémi Denis-Courmont remi at remlab.net
Wed Jul 26 10:10:11 CEST 2017


Le 26 juillet 2017 09:29:35 GMT+03:00, Steve Lhomme <robux4 at gmail.com> a écrit :
>On Tue, Jul 25, 2017 at 9:25 PM, Rémi Denis-Courmont <remi at remlab.net>
>wrote:
>> Le tiistaina 25. heinäkuuta 2017, 20.58.44 EEST Steve Lhomme a écrit
>:
>>> Can you point to doc about that because I couldn't understand how it
>works
>>> in the regular case (and it does). Because my understanding of
>container_of
>>> is that it gives the starting offset of the field in the structure.
>Except
>>> in this case it's the end of the structure.
>>
>> Uh? container_of(p,t,m) returns a pointer to a structure of type 't'
>that
>> contains a member 'm', to which 'p' points.
>
>Yes I meant offsetof().
>
>With gcc offsetof(struct vlc_object_internals, aligned_end) gives 160.
>Which is also sizeof(struct vlc_object_internals). Which seems very
>odd to me. It's as if aligned_end had no size at all.
>
>And on my other compiler offsetof() 152 when the sizeof() is 160. And
>because of the the vlc_internals/externals is broken. They don't point
>to the same area.
>
>That's I think
>1/ having a static assert to make sure what is expected is there
>2/ accessing the pointers in a consistent way is better
>
>> See MMDevice callbacks for a good example.
>>
>> --
>> 雷米‧德尼-库尔蒙
>> https://www.remlab.net/
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

A flexible array structure member has a size of zero by definition. What you call "very odd" is in fact intrinsic and required by both C99 and C11.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170726/e682801b/attachment.html>


More information about the vlc-devel mailing list