This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
c++, gcc3.2.2 and bitwise operations
- From: "Chris Croswhite" <ccroswhite at get2chip dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 18 Feb 2003 17:33:19 -0800 (PST)
- Subject: c++, gcc3.2.2 and bitwise operations
- Reply-to: ccroswhite at get2chip dot com
How can I play with the guts of a variable one bit at a time in c++? That
is, I want to do something like this,
long long val =0x4000000000000001;
((int*)(&val)[1]) &= 0x0;
(this should set the first bit to zero). This worked with gcc 2.95.x, but I
understand now that the casting (&val)[1] (to an array) is "undefined" and
therefore not predictible.
Could anyone give me hand?
TIA,
Chris