使用命名空间
#include <boost/spirit/home/support/detail/endian/endian.hpp>
#include <boost/crc.hpp>
using namespace boost::spirit::detail;
typedef crc_optimal<8, 0x31, 0, 0, true, true> crc_1_wire_type;
crc_1_wire_type crcOpt;
crcOpt.process_bytes(&(tempHeadTodsp),sizeof(SPEC_DATAHEAD));
tempHeadTodsp.crc = crcOpt.checksum();
store_big_endian<int,4>(&tempAskTodsp.Content_Tag,content)
size_t>
C中的转换方法
#include <arpa/inet.h>
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
- typedef union{
- float f;
- char c[4];
- }FLOAT_CONV;
-
-
- /************************************************************
- Conversion little endian float data to big endian
- *************************************************************/
- static float __ltobf(float data)
- {
- FLOAT_CONV d1, d2;
-
- d1.f = data;
-
- d2.c[0] = d1.c[3];
- d2.c[1] = d1.c[2];
- d2.c[2] = d1.c[1];
- d2.c[3] = d1.c[0];
-
- return d2.f;
- }