Hey everyone,
I have a quick question for the members in this community:
Do you prefer structs and bit masks over bit fields or not?
This is using C or C++, of course. I useually just use structs+bit masks to access individual bits, but am now coinsidering the use of bit fields instead as they dont require bit masks to access its members, and looks alot nicer as well.
This makes me wonder: What do you use in your OS?
Bit fields
Bit fields
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Actually i wrote a valuetype base class with bit access and have int8-int64 and uint8-uint64 types derive from it. So i can use intValue(2,16) = -1; which would set the bits 2-18 or intValue to 1, however this is achieved by bitsmasks (to answer your question).
In OS programming a lot of the bits location, if not all, are fixed which makes very efficient code for my valuetype classes, but i never tested this with bit fields though.
In OS programming a lot of the bits location, if not all, are fixed which makes very efficient code for my valuetype classes, but i never tested this with bit fields though.
Author of COBOS