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

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

        <tfoot id='i4uZr'></tfoot>
        • <bdo id='i4uZr'></bdo><ul id='i4uZr'></ul>

        Visual C++ 相当于 GCC 的 __attribute__ ((__packed__))

        时间:2023-09-19
            <bdo id='velLL'></bdo><ul id='velLL'></ul>
            <i id='velLL'><tr id='velLL'><dt id='velLL'><q id='velLL'><span id='velLL'><b id='velLL'><form id='velLL'><ins id='velLL'></ins><ul id='velLL'></ul><sub id='velLL'></sub></form><legend id='velLL'></legend><bdo id='velLL'><pre id='velLL'><center id='velLL'></center></pre></bdo></b><th id='velLL'></th></span></q></dt></tr></i><div id='velLL'><tfoot id='velLL'></tfoot><dl id='velLL'><fieldset id='velLL'></fieldset></dl></div>

          • <small id='velLL'></small><noframes id='velLL'>

                    <tbody id='velLL'></tbody>
                1. <legend id='velLL'><style id='velLL'><dir id='velLL'><q id='velLL'></q></dir></style></legend>
                2. <tfoot id='velLL'></tfoot>
                  本文介绍了Visual C++ 相当于 GCC 的 __attribute__ ((__packed__))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  对于某些编译器,结构体有一个打包说明符,例如 ::

                  <前>RealView ARM 编译器具有__packed"Gnu C 编译器有__attribute__ ((__packed__))"Visual C++ 没有等效项,它只有#pragma pack(1)"

                  我需要一些可以放入结构定义的东西.

                  任何信息/黑客/建议?TIA...

                  解决方案

                  您可以为 GNU GCCMSVC 定义 PACK 如下:

                  #ifdef __GNUC__#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))#万一#ifdef _MSC_VER#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))#万一

                  并像这样使用它:

                  PACK(struct myStruct{一个;国际b;});

                  For some compilers, there is a packing specifier for structs, for example ::

                  RealView ARM compiler has "__packed"
                  Gnu C Compiler has "__attribute__ ((__packed__))"
                  Visual C++ has no equivalent, it only has the "#pragma pack(1)"
                  

                  I need something that I can put into the struct definition.

                  Any info/hack/suggestion ? TIA...

                  解决方案

                  You can define PACK like as follows for GNU GCC and MSVC:

                  #ifdef __GNUC__
                  #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
                  #endif
                  
                  #ifdef _MSC_VER
                  #define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
                  #endif
                  

                  And use it like this:

                  PACK(struct myStruct
                  {
                      int a;
                      int b;
                  });
                  

                  这篇关于Visual C++ 相当于 GCC 的 __attribute__ ((__packed__))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么这个循环会产生“警告:迭代 3u 调用未定义 下一篇:如何在 GCC 中摆脱“已弃用的从字符串常量到‘

                  相关文章

                  最新文章

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

                  • <bdo id='xQbAi'></bdo><ul id='xQbAi'></ul>

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

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