码迷,mamicode.com
首页 > 其他好文 > 详细

Byte Order, Size, and Alignment

时间:2015-06-03 11:29:50      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

Byte Order, Size, and Alignment

  By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler).

  Alternatively, the first character of the format string can be used to indicate the byte order, size and alignment of the packed data, according to the following table:

  技术分享

  If the first character is not one of these, ‘@‘ is assumed.

  Native size and alignment are determined using the C compiler’s sizeof expression. This is always combined with native byte order.

  The form ‘!‘ is available for those poor souls who claim they can’t remember whether network byte order is big-endian or little-endian.

  

Notes:

  1. Padding is only automatically added between successive structure members. No padding is added at the beginning or the end of the encoded struct. 
  2. No padding is added when using non-native size and alignment, e.g. with ‘<’, ‘>’, ‘=’, and ‘!’. 

Byte Order, Size, and Alignment

标签:

原文地址:http://www.cnblogs.com/tekka/p/4548602.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!