The usefulness of bit packing

The Partridge Family were neither partridges nor a family. Discuss.
Posts: 4169
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: The usefulness of bit packing

Post by albinopapa » August 25th, 2019, 5:38 am

Slidy wrote:
August 25th, 2019, 3:30 am
chili wrote:
August 21st, 2019, 3:28 pm
Definitely disagree there. If I type Foo and hit my intellisense, it tells me i got 3 bools and tells me their names. EZPZ.
With your situation, all I get is <int flags>. Oh great, now I gotta go digging in the docs to try and find this shit. :kms:

Flags are easier for skimming code (esp. without an IDE) tho, I will admit that.
You just type the FLAG_ prefix and all the options come up. Also typically the enum will be typed (in which case you could also do EnumType:: and get all the options) or the function will have a comment telling you which flags are relevant, no docs digging necessary.
I believe chili was talking about
void Foo( bool _flag0, bool _flag1, bool _flag2 )
as opposed to
void Foo( int _flags )

Comments are guaranteed, neither accurate nor complete.
Luckily, with the WinAPI at least, the flag macros are prefixed
CS_ for class style
WS_ for window style
WM_ for window message
SW_ for show window
and so on, so it is a little easier to at least know which set of flags can be sent to Foo( int )
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. -

Post Reply