Search code examples
c++boost

Including two headers which are not available at the same time


There is a code repository including these two headers from Boost library at the same time:

#include <boost/nowide/cstdio.hpp> // => Not found with Boost 1_72_0
#include <boost/detail/endian.hpp> // => Not found with Boost 1_74_0 or 1_73_0

First I installed Boost 1_74_0 or 1_73_0 and the <boost/detail/endian.hpp> was not found. According to this post, I installed Boost 1_72_0, the problem got resolved, but now <boost/nowide/cstdio.hpp> is not found!

I'm trying to figure out which Boost version to use to have both headers. I feel like I'm missing something, I appreciate any help =)

SOLUTION

Using Boost 1_74_0 and:

  • Replace #include <boost/detail/endian.hpp> with #include <boost/predef/other/endian.h>
  • Replace #ifndef BOOST_LITTLE_ENDIAN with #if BOOST_ENDIAN_BIG_BYTE
  • Replace #ifdef BOOST_LITTLE_ENDIAN with #if BOOST_ENDIAN_LITTLE_BYTE

Solution

  • If you read the <boost/detail/endian.hpp> header file it has a comment:

    // Use the Predef library for the detection of endianess.

    Followed by

    #include <boost/predef/detail/endian_compat.h>
    

    It simply seems that the header you used have been obsolete or deprecated for a while, and finally removed.

    So the solution is to migrate to the Predef library and its headers.


    As for <boost/nowide/cstdio.hpp> it's part of the Nowide library which was added with Boost 1.73.0.