You should review static const
vs #define
in C.
It sounds as if you are using enumerations of the general form:
enum
{
FLAG_A = 0x00000001, FLAG_B = 0x00000002, FLAG_C = 0x00000004, FLAG_D = 0x00000008,
...
};
You also combine these various enumeration values into a (32-bit) unsigned int
value with bitwise operations.
Now you've reached the limit; you have more than 32 flags (and I trust they're more meaningfully named than in my example).
You could decide to start a new series of enumerations, using a second 32-bit (unsigned) integer to store the bits. This has the merit of keeping the symbols in the debuggable program (unlike #define
constants which are seldom available even in debuggable programs). The downside is that you might need to pass two values where previously you passed one.
If it is imperative to keep the flags in a single variable, you'll need to review whether it is better to use an unsigned long long
, or perhaps a structure with two unsigned int
values would work.
I agree that it is better not to use bitfields, though they might work sufficiently well. I would also go to considerable pains to avoid using #define
, and would probably use either two 32-bit variables or a structure. A lot depends on your code base, and how extensively the values will be used.