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