Skip to content

Commit 8ad666f

Browse files
committed
deduce endianness of the platform
1 parent 79700a1 commit 8ad666f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/boost/json/detail/config.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,24 @@
250250
# endif
251251
#endif
252252

253+
254+
#if ! defined(BOOST_JSON_BIG_ENDIAN) && ! defined(BOOST_JSON_LITTLE_ENDIAN)
255+
// Copied from Boost.Endian
256+
# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
257+
# define BOOST_JSON_LITTLE_ENDIAN
258+
# elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
259+
# define BOOST_JSON_BIG_ENDIAN
260+
# elif defined(__LITTLE_ENDIAN__)
261+
# define BOOST_JSON_LITTLE_ENDIAN
262+
# elif defined(__BIG_ENDIAN__)
263+
# define BOOST_JSON_BIG_ENDIAN
264+
# elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
265+
# define BOOST_JSON_LITTLE_ENDIAN
266+
# else
267+
# error The Boost.JSON library could not determine the endianness of this platform. Define either BOOST_JSON_BIG_ENDIAN or BOOST_JSON_LITTLE_ENDIAN.
268+
# endif
269+
#endif
270+
253271
BOOST_JSON_NS_BEGIN
254272
namespace detail {
255273

0 commit comments

Comments
 (0)