This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to disable "is too small to hold all values of" warnings for enums in bitfields

I use bitfields with enum classes to strongly type as much as I can. Like:

enum class ShutdownMode : uint8_t {
    NormalOperation = 0b00,
    ShutdownMode = 0b01,
    BurstMode = 0b10,
    // 11 = Unimplemented: this setting has no effect
};
    // ...
    struct {
        ShutdownMode shutdownMode : 2;
    };
    // ...

However I get errors all the time like:

src/Peripherals/MCP96.hpp:167:35: warning: 'MCP96::<anonymous union>::<anonymous struct>::shutdownMode' is too small to hold all values of 'enum class MCP96::ShutdownMode'
 ShutdownMode shutdownMode : 2;

How can I disable or suppress this warning and still use enum classes as struct members with a small bitfield size?