RE: Merging changes to volatile bitfield structs

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

 



Hi Phil,

Hmmm, try this...

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

volatile S s;

void f()
{
  S x;
  x.a = 0;
  x.b = 0;
  S& nonvolatile_s = const_cast<S&>(s);
  nonvolatile_s = x;
}

If you are using C++ anyway, I strongly recommend avoiding bitfields and do the shifting/masking in accessor/mutator functions yourself.  That'll help encapsulation, too.

--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