The usefulness of bit packing

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 3801
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 )
#define FOO_FLAGS_DESTROY_WORLD 0x01
#define FOO_FLAGS_SAVE_ANIMALS 0x02
#define FOO_FLAGS_POISON_WATER 0x04
#define FOO_FLAGS_CULTIVATE_SOIL 0x08
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. - gameprogrammingpatterns.com

Post Reply