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] | |
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 Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |