RE: Merging changes to volatile bitfield structs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Phil,

My apologies, I assumed you were working in C, not C++.

Try this...

struct S
{
  union
  {
    struct
    {
      unsigned a : 1;
      unsigned b : 31;
    };

    unsigned ab;
  } m;

  void S::operator = (S const& in) volatile
  {
    m.ab = in.m.ab;
  }
};

volatile S s;

void f()
{
  S x;
  x.m.a = 0;
  x.m.b = 0;
  s = x;
}

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux