Alexander Panek Wrote: > On Tue, 15 Mar 2005 21:23:23 +0100, Anders F Björklund <[email protected]> > wrote: > > > Alexander Panek wrote: > > > >> just wondered if there`s a common way to edit single bits in a byte? in > >> C and C++ there were only crappy 'workarounds', but as D has a > >> single-bit datatype it would be great to have an operator to > >> read/write single bits in a byte-variable. > > > > Use the bit[] type. Just be aware that it always aligns the memory used > > to even powers of 32 bits (4 bytes), if unioned with for instance byte. > > > > See http://www.prowiki.org/wiki4d/wiki.cgi?BitsAndBools > > > > --anders > > Well, I use a bit-array. But it seems like the compiler does not want me > to do this :o ! > > I use this code to copy a bit out of a byte into a bit-variable: > > [code] > while(offset_ascii < 8) { > result[offset_sms] = (b & (true << offset_ascii++)) << offset_sms++; // > > line 18 > } > [/code] > > DMD gives me this error: > " smscode.d(18): cannot implicitly convert expression (cast(int)(b) & 1 << > offset_ascii++) of type int to bit " > > Thanks, > an hopefully Alex ;) > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
I tried a bit... I can't get it to work with bud... only dmd will compile the source. When I first compile with dmd and then with bud, it works with bud, too - but only until I didn't use the -clean flag when I build the exe-file.
