欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

大小端转换 博客分类: c++  

程序员文章站 2024-03-19 10:17:04
...

https://*.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c

 

GCC 平台 : int32_t __builtin_bswap32 (int32_t x) ;int64_t __builtin_bswap64 (int64_t x)

 

If you're using Visual C++ do the following: You include intrin.h and call the following functions:

For 16 bit numbers:

unsigned short _byteswap_ushort(unsigned short value);

For 32 bit numbers:

unsigned long _byteswap_ulong(unsigned long value);

For 64 bit numbers:

unsigned __int64 _byteswap_uint64(unsigned __int64 value);