<i id='FqPn5'><tr id='FqPn5'><dt id='FqPn5'><q id='FqPn5'><span id='FqPn5'><b id='FqPn5'><form id='FqPn5'><ins id='FqPn5'></ins><ul id='FqPn5'></ul><sub id='FqPn5'></sub></form><legend id='FqPn5'></legend><bdo id='FqPn5'><pre id='FqPn5'><center id='FqPn5'></center></pre></bdo></b><th id='FqPn5'></th></span></q></dt></tr></i><div id='FqPn5'><tfoot id='FqPn5'></tfoot><dl id='FqPn5'><fieldset id='FqPn5'></fieldset></dl></div>

  1. <tfoot id='FqPn5'></tfoot>

    1. <legend id='FqPn5'><style id='FqPn5'><dir id='FqPn5'><q id='FqPn5'></q></dir></style></legend>

      • <bdo id='FqPn5'></bdo><ul id='FqPn5'></ul>
    2. <small id='FqPn5'></small><noframes id='FqPn5'>

      结构位域最大大小(C99,C++)

      时间:2023-07-01

          <tbody id='3dioS'></tbody>

      1. <legend id='3dioS'><style id='3dioS'><dir id='3dioS'><q id='3dioS'></q></dir></style></legend>
      2. <small id='3dioS'></small><noframes id='3dioS'>

              <bdo id='3dioS'></bdo><ul id='3dioS'></ul>

              • <i id='3dioS'><tr id='3dioS'><dt id='3dioS'><q id='3dioS'><span id='3dioS'><b id='3dioS'><form id='3dioS'><ins id='3dioS'></ins><ul id='3dioS'></ul><sub id='3dioS'></sub></form><legend id='3dioS'></legend><bdo id='3dioS'><pre id='3dioS'><center id='3dioS'></center></pre></bdo></b><th id='3dioS'></th></span></q></dt></tr></i><div id='3dioS'><tfoot id='3dioS'></tfoot><dl id='3dioS'><fieldset id='3dioS'></fieldset></dl></div>
                <tfoot id='3dioS'></tfoot>
                本文介绍了结构位域最大大小(C99,C++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                位结构域的最大位宽是多少?

                What is maximal bit width for bit struct field?

                struct i { long long i:127;}
                

                我可以在 struct 中定义一个位域,位域的大小最大为 128 位、256 位或更大吗?有一些超宽向量类型,例如 sse2(128 位)、avx1/avx2(256 位)、avx-512(下一个至强融核为 512 位)寄存器;以及 gcc 中的 __int128 等扩展.

                Can I define a bit field inside struct, with size of bitfield up to 128 bit, or 256 bit, or larger? There are some extra-wide vector types, like sse2 (128-bit), avx1/avx2 (256-bit), avx-512 (512-bit for next Xeon Phis) registers; and also extensions like __int128 in gcc.

                推荐答案

                C99 §6.7.2.1,第 3 段:

                C99 §6.7.2.1, paragraph 3:

                指定的表达式位域的宽度应为具有的整数常量表达式不应该的非负值超过对象中的位数指定的类型,如果省略了冒号和表达式.如果值为零,声明不得有声明符.

                The expression that specifies the width of a bit-field shall be an integer constant expression that has nonnegative value that shall not exceed the number of bits in an object of the type that is specified if the colon and expression are omitted. If the value is zero, the declaration shall have no declarator.

                C++0xa §9.6,第 1 段:

                C++0xa §9.6, paragraph 1:

                ... 常量表达式应为积分常数表达式值大于或等于零.积分常数的值表达式可能大于对象中的位数的表示 (3.9)位域的类型;在这种情况下额外的位用作填充位并且不参与价值位域的表示(3.9).

                ... The constant-expression shall be an integral constant expression with a value greater than or equal to zero. The value of the integral constant expression may be larger than the number of bits in the object representation (3.9) of the bit-field’s type; in such cases the extra bits are used as padding bits and do not participate in the value representation (3.9) of the bit-field.

                所以在 C 中你根本不能这样做,而在 C++ 中它不会做你想要的.

                So in C you can't do that at all, and in C++ it won't do what you want it to.

                这篇关于结构位域最大大小(C99,C++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:此错误是什么意思:“错误:'type_name' 之前的预期说明符限定符列表"? 下一篇:“Y 未命名类型"C++ 中的错误

                相关文章

                <tfoot id='RqzMt'></tfoot>

                  <small id='RqzMt'></small><noframes id='RqzMt'>

                  <legend id='RqzMt'><style id='RqzMt'><dir id='RqzMt'><q id='RqzMt'></q></dir></style></legend>

                  1. <i id='RqzMt'><tr id='RqzMt'><dt id='RqzMt'><q id='RqzMt'><span id='RqzMt'><b id='RqzMt'><form id='RqzMt'><ins id='RqzMt'></ins><ul id='RqzMt'></ul><sub id='RqzMt'></sub></form><legend id='RqzMt'></legend><bdo id='RqzMt'><pre id='RqzMt'><center id='RqzMt'></center></pre></bdo></b><th id='RqzMt'></th></span></q></dt></tr></i><div id='RqzMt'><tfoot id='RqzMt'></tfoot><dl id='RqzMt'><fieldset id='RqzMt'></fieldset></dl></div>
                    • <bdo id='RqzMt'></bdo><ul id='RqzMt'></ul>