A better way to set flags
How many flags do you need? If you can settle with only 32 or 64 different flags instead of a generic-length array of flags, then it would probably be better to allocate the flags in a simple unsigned long, to save your program from all the runtime calculations.

The main efficiency problem in your code is that the compiler can't know the value of the "flag" parameter, so it must calculate division and modulo in runtime to know where to set the flag.

Your code is also limited to one flag set at a time. A common way to write code like this from the caller's side is setFlag (&amp;the_struct, FLAG_THIS | FLAG_THAT);. The whole Windows API uses flags like that, with bitwise OR. If you stored the flags in an unsigned long that wouldn't be a problem, as you wouldn't need to index the flag array. Then the caller wouldn't need to call your function over and over to set several flags at the same time.

Surely it must be ok to group flags into 32/64 bit variables, related to a specific code module?