使用升压的字节序转换
Endian conversion using boost
我按照所谓的提升手册来转换(交换)字节序。
尽管他们的代码比他们的手册更具可读性,但有人可以解释一下我应该如何修复以下代码吗?
呵呵.cpp
#include <iostream>
#include <boost/array.hpp>
#include <boost/endian/conversion.hpp>
int main () {
std::cout << boost::endian::endian_reverse(5);
return 0;
}
做:
g++ hh.cpp -o hh -Wall -Wconversion -Wfatal-errors -Wextra -std=c++11 -lboost_system -lrt -lboost_wave -larmadillo -lboost_thread
错误:
hh.cpp:3:39: fatal error: boost/endian/conversion.hpp: No such file or directory
#include <boost/endian/conversion.hpp>
^
compilation terminated.
更新
其他升压标头都包含在内。只有endian
有问题。
ls /usr/include/boost/*
http://pastebin.com/nCciracE
更新
$ cat /usr/include/boost/version.hpp
结果:
// Boost version.hpp configuration header file ------------------------------//
// (C) Copyright John maddock 1999. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for documentation
#ifndef BOOST_VERSION_HPP
#define BOOST_VERSION_HPP
//
// Caution, this is the only boost header that is guarenteed
// to change with every boost release, including this header
// will cause a recompile every time a new boost version is
// released.
//
// BOOST_VERSION % 100 is the patch level
// BOOST_VERSION / 100 % 1000 is the minor version
// BOOST_VERSION / 100000 is the major version
#define BOOST_VERSION 105400
//
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
// but as a *string* in the form "x_y[_z]" where x is the major version
// number, y is the minor version number, and z is the patch level if not 0.
// This is used by <config/auto_link.hpp> to select which library version to link to.
#define BOOST_LIB_VERSION "1_54"
#endif
endian
库是在 boost 1.58 版本中引入的。您有 1.54,此版本中没有endian
库。您应该将 boost 更新到 1.58+,要么不使用endian
库。
相关文章:
- 如何在连接器 C++ 中将原始字节转换为字符串
- 将 char[] 数组转换为字节,然后将字节转换为 int,反之亦然
- 如何在 c++ 中将字节转换为 ASCII 十六进制表示形式?
- OPENSSL 将二进制字节转换为 SHA256 C++
- 如何将音频字节转换为样本
- C++ 如何将 char[] 中的多个字节转换为一个整数
- 删除字节转换的char*
- 如何将二进制字节转换为可打印的数值
- 将 MFRC522 UID 十六进制字节转换为可打印的小数
- 用c++将十六进制字符串切碎,并将中的每个字节转换为十进制
- Qt是否有一种将字节转换为int的方法,反之亦然
- UCS-4 到 Solaris 上的多字节转换
- 使用 C++ 将四个字节转换为整数
- 将字节转换为无符号整数的最快方法
- 如何在mac上将多字节转换为宽字符
- 将字节转换为整数
- 在Arduino错误时将4个字节转换为长字节
- 更正从C++到delphi AnsiString的字节转换
- 用C++将4个字节转换为3个字节
- 正在将字节转换为char数组,然后再转换回来