This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Merging changes to volatile bitfield structs
- From: "Phil Endecott" <spam_from_gcc_help_2 at chezphil dot org>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Fri, 19 Oct 2007 11:53:40 +0100
- Subject: Re: Merging changes to volatile bitfield structs
- References: <C33A0B3C.26049%eljay@adobe.com>
John Love-Jensen wrote:
Hi Phil,
Can anyone share their preferred approach to this sort of problem?
Reg workingReg = reg;
workingReg.a = 0;
workingReg.b = 0;
workingReg.c = 0;
reg = workingReg;
I'm having trouble working out the necessary casting:
struct S {
unsigned a : 1;
unsigned b : 31;
};
volatile S s;
void f() {
S x;
x.a = 0;
x.b = 0;
s = x;
}
This fails to compile with g++:
$ g++ -W -Wall -c /tmp/voltest.cc
/tmp/voltest.cc: In function â??void f()â??:
/tmp/voltest.cc:12: error: passing â??volatile Sâ?? as â??thisâ?? argument of
â??S& S::operator=(const S&)â?? discards qualifiers
It does compile as C, if I replace 'S' with 'struct S'. I have tried
various casts but haven't yet found the right one. Any ideas anyone?
Thanks,
Phil.