https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50909

Evan Miller <emmiller at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |emmiller at gmail dot com

--- Comment #16 from Evan Miller <emmiller at gmail dot com> ---
An unusual but viable workaround for this problem is:

  #pragma options align=power
  #pragma options align=power
  #pragma options align=power
  #pragma options align=power
  #pragma options align=power
  #include <IOKit/usb/USB.h>

This technique pre-loads the "options" alignment stack with five default
values. When

  #pragma pack(1)

is encountered in the header file, the global alignment is set to 1 byte. Then
when

  #pragma options align=reset

is encountered, a value is popped off the options stack and the global
alignment is set to the value at the top of the stack ("power" which is
implemented as the platform default). So the pack and options pragmas inside
the header file end up having the desired effect.

If the number of "align=power" pragmas before the header inclusion equals the
number of "align=reset" pragmas inside the header, then after inclusion, the
alignment stack will be whatever it was before all the "align=power" pragmas.
It probably won't hurt anything to have extra values on the alignment stack, so
you can add a few more to be safe.

Reply via email to