Size of a bitfield member?

后端 未结 6 1073
傲寒
傲寒 2020-12-29 07:42

Would anyone know how to extract the size of a bit-field member. The below code naturally gives me the size of an integer, but how do I find out how many bits or b

6条回答
  •  -上瘾入骨i
    2020-12-29 07:51

    There is no way to get this information (apart from reading the declaration yourself). As per the standard, [C++11]expr.sizeof§1, it's illegal to call sizeof on a bit-field:

    The sizeof operator shall not be applied to ... an lvalue that designates a bit-field.

提交回复
热议问题