[haiku-commits] Re: haiku: hrev52133 - src/apps/mediaconverter

  • From: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 27 Jul 2018 00:05:11 +0200

Hi,

On Thu, Jul 26, 2018 at 11:26 PM Stephan Aßmus <superstippi@xxxxxx> wrote:

Again, thanks for all the info, I've learned a lot. I guess that's what
I get for being mostly self-taught. IIRC, I even learned about unions
mostly from seeing how media_format works. What I don't understand is
how code in one place can even know which union member has been
initialized in another place of the code. It would seem to make it
necessary to always have fields in unions wich carry this information
(such as media_format::type). But I don't mean for you to keep digging,
I should do that myself.


You can't know which member is active. This is leaved completely to the
programmer logic, by standard.



In any case, in my previous mails, I think more than once, I was asking
the honest question if memset() may have unwanted side-effects, or be
ineffective at fully initializing the union. A simple "Yes, please
google it" would have been fine for me. And in fact I did google it, but
only found stuff that confirmed what I learned before. (In essence, that
media_format should be "trivially copyable".) Alter I saw that
media_format also has the meta_data stuff,


The only fact that media_format has a user-defined copy constructor makes
it non-trivially copiable.

-- 
Saluti,
Dario

Other related posts: