简体   繁体   English

boost :: endian和非1字节原子字节序?

[英]boost::endian and non-1 byte atomic endianness?

I have read on Wikipedia that there are three main types of endianness: 我在Wikipedia上读到,字节序主要有三种类型:

  • big endian 大端
  • little endian 小端
  • middle endian 中端

boost::endian focuses on the two firsts because: boost::endian专注于两个第一,因为:

PDP-11 and the other middle endian approaches are interesting historical curiosities but have no relevance to today's C++ developers. PDP-11和其他中端方法是有趣的历史好奇心,但与当今的C ++开发人员无关。

But I also read on Wikipedia that there are 8-bit and 16-bit versions (and maybe others?) of little and big endianness. 但是我也从Wikipedia上读到,有8-bit16-bit版本(可能还有其他版本),大小不一。

  • Is boost::endian managing both versions? boost::endian是否同时管理两个版本?
  • If yes, how? 如果是,怎么办?
  • If not, why? 如果没有,为什么?

I don't know much about the boost libraries, but endianness pervades pretty much everything in a computer and can be a headache when dealing with trying to write endian-neutral code. 我对boost库了解不多,但是endianness遍及了计算机中的几乎所有内容,在尝试编写与endian无关的代码时可能会让人头疼。 If you have a 128 bit integer the little endian computer's pointer will point to the low order bit while the big endian pointer will point to the high order bit. 如果您有一个128位整数,则小字节序计算机的指针将指向低位,而大字节序计算机的指针将指向高位。 Depending on the datatypes the pointer could be anywhere up and down the memory in a big endian system. 根据数据类型,指针可能位于大字节序系统中内存上下的任何位置。 Since the little-endian system always points to the low order byte and there's no datatype smaller than a byte, type coercion becomes a no-op on a little endian machine. 由于little-endian系统始终指向低位字节,并且没有小于字节的数据类型,因此类型强制转换在little-endian机器上变为无操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM