why padding is not happening in this case?

前端 未结 4 1646
半阙折子戏
半阙折子戏 2020-12-23 15:14

As per my knowledge, By default 4-byte alignment will be done. say

typedef struct
{
     int data7;  
     unsigned char data8;
     //3 -bytes will be added         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 15:39

    data7 is a 4-byte item, so the compiler will normally attempt to align it to an address that's a multiple of 4.

    data1 is a one-byte item, so the compiler won't try to align it to any particular boundary (i.e., there would be no real gain from doing so).

提交回复
热议问题