__attribute__((pack))的用法

 typedef struct shm_head {
      volatile int head;
      volatile int tail;
      atomic_t blk_cnt;

  } __attribute__ ((packed)) shm_head_t;

告訴編譯器取消結構在編譯過程中的優化對齊, 按照實際佔用字節數對齊,是GCC特有的語法.




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章