[sdiy] Pointers in C

René Schmitz uzs159 at uni-bonn.de
Sat Dec 31 20:14:46 CET 2011


Am 31.12.2011 18:05, schrieb Colin f:
>
>> I'd just dereference the 32bit pointer, and get the
>> individual bytes by bit masking and shifting instead.
>> i.e.
>>
>> unsigned long allbytes = *my_unsigned_long_ptr; unsigned char
>> LSByte = allbytes&&  0x0ff; unsigned char secondbyte =
>> (allbytes&&  0x0ff00)>>8; unsigned char thirdbyte = (allbytes
>> &&  0x0ff0000L)>>16; unsigned char MSByte = (allbytes&&
>> 0x0ff000000L)>>24;
>>
>> In my opinion this gives much less confusion with endianess...
>
> It gives rather more confusion between&  and&&  though ;-)
> You want bitwise rather than logical.

Oops... Right, it seems logical. :-)
(Thats what you get when you're used to being called upon this by the 
JAVA compiler...)

Cheers,
  René

-- 
uzs159 at uni-bonn.de
http://www.uni-bonn.de/~uzs159



More information about the Synth-diy mailing list