簡體   English   中英

使用boost進行Endian轉換

[英]Endian conversion using boost

我按照所謂的升級手冊來轉換(交換)端序。

盡管他們的代碼比他們的手冊更具可讀性,但有人可以解釋我應該如何修復以下代碼嗎?

hh.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庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM