I have some bit field flag state for a uint32 variable and for these flags it is a nf by some variable values Is passed as the argument for.
I have to add about 20 more flags to it, what are my best options? Extend it to 64 bits or use it as an array of 2 32bits?
Extending up to 64 bits will help me to use the compiler extension, because the input is 32bits wide. But using an array is working more than that.
My code compiles it on 32 and 64 bit compilers, and runs on windows, Linux and Mac.
Thanks in advance.
I will use a STL bitset then my desire 2 does not have a power. With normal calculation, it will be indicative only in bitsets. You can get a vector & lt; Bool & gt; can also be used.
The main advantage will be portability because your flag set will now fit in the general enum range of any platform.
Example:
enum errorFlags {resemblance, framing, overrun, errorflag_shape}; Std :: bitset & lt; ErrorFlags_size & gt; FlagSet; . . . // flagSet [framing] = true; with one of these set string error conditions; Flagset.set (ready); // Set framing error status flag to any of these [framing] = false; Flagset.reset (ready); // This test for framing error condition (if flag set [framing]) {// We have a framing error}
Comments
Post a Comment