I suggest you think for half a second about the assembly code that will be generated by manipulating the bitfield.
Name:
Anonymous2009-05-08 17:59
>>2
Because I want to get advice from EXPERT C PROGRAMMERS with 20+ years of experience .
>>4
I have no idea, this is my first real C project and I've never done any assembly before (it's on my to-do list, though). I suppose it would involve bitwise operations, but I wonder which version will get more optimized/be more portable.
I'd guess they'd be the same (and that the compiler would turn a reference to the structure into the macro during compilation), but again it is smartest to test it because it is also compiler-dependent one what will actually be done.
Bitfields are usually accessed using simple and/test/sh*/jcc operations(for x86*). You are using a 'shr' and 'and', either way it'll be very fast, but if you want, examing the compiled code and get the intel processor manuals to decide which will be slightly faster than the other for the specific compiler(and the used settings) and target architecture.