This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Merging changes to volatile bitfield structs


John (Eljay) Love-Jensen wrote:
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;
}

Thanks, but.... that's rather unpleasant. Isn't there some way of solving it with casts?



Phil.






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]