简体   繁体   中英

What is the difference between `BOOST_ENDIAN_BIG_BYTE` and `BOOST_ENDIAN_BIG_WORD`?

In the latest release of boost, there are 4 endian macros defined:

* `BOOST_ENDIAN_BIG_BYTE`, byte-swapped big-endian.
* `BOOST_ENDIAN_BIG_WORD`, word-swapped big-endian.
* `BOOST_ENDIAN_LITTLE_BYTE`, byte-swapped little-endian.
* `BOOST_ENDIAN_LITTLE_WORD`, word-swapped little-endian.

https://www.boost.org/doc/libs/1_69_0/boost/predef/other/endian.h

I'm unclear on the distinction between _BYTE and _WORD macros.

Word-swapped endiannes refer to (now prehistoric) hardware which could be considered middle-endian: two halves of a word would be swapped, but byte-order in the half-word would be not. PDP-11 is probably the most famous architecture to have this.

The reason for boost to support this endiannes is unclear, to be honest, as I am pretty sure boost is generally not supported well on those prehistoric architectures. For example, C++ standard makes do with little and big options: https://en.cppreference.com/w/cpp/types/endian

See more on middle endian: https://en.wikipedia.org/wiki/Endianness#Middle-endian

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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