UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 38592

12.1 EDK - mb-gcc does not properly pack structures using bitfields

Description

When I attempt to pack a variable with bitfields using the "packed" attribute, the variable does not match the size expected.

解决方案


GNU GCC has a known issue where bitfields on a "char" type variable is not being packed properly. This is documented in the online GCC documentation: http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html

NOTE: The 4.1, 4.2 and 4.3 series of GCC ignore the "packed" attribute on bit-fields of type char. This has been fixed in GCC 4.4 but the change can lead to differences in the structure layout. See the documentation of -Wpacked-bitfield-compat for more information."

Also, note that this can also apply to "enum" types. An "enum" is not defined as being a specific size in the ANSI/ISO C Specification. This means that it could be placed in a "char", "short", or "int" type.

To work around this issue, use an "int" or "short" type rather than a "char" or "enum".
AR# 38592
创建日期 10/13/2010
Last Updated 10/14/2010
状态 Active
Type 综合文章
Tools
  • EDK - 12.1
  • EDK - 12.2
  • EDK - 12.3