Why doesn't GCC optimize structs?

前端 未结 7 1319
耶瑟儿~
耶瑟儿~ 2020-11-28 05:58

Systems demand that certain primitives be aligned to certain points within the memory (ints to bytes that are multiples of 4, shorts to bytes that are multiples of 2, etc.).

相关标签:
7条回答
  • 2020-11-28 06:54

    gcc does not reorder the elements of a struct, because that would violate the C standard. Section 6.7.2.1 of the C99 standard states:

    Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared.

    0 讨论(0)
提交回复
热议问题