How to enforce the struct bit order with the GCC compiler?

坚强是说给别人听的谎言 提交于 2019-11-30 12:43:53
kichik

Which version of GCC are you using and which platform? A pragma exists that may do the trick, but it doesn't work on x86 starting with GCC 4.

#pragma reverse_bitfields on

More details at:

http://groups.google.com/group/gnu.gcc.help/browse_thread/thread/747918655affa5c0?pli=1

If you don't mind rebuilding GCC, all the relevant build settings are here (search for bitfield):

http://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html

Some details about bitfields being bad:

C/C++: Force Bit Field Order and Alignment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!