‘asio::stream_file’ has not been declared error on Linux with GCC
I built BOOST 1.89 on Ubuntu 24.04 with GCC 13.3.0 using the following commands:
./bootstrap.sh --prefix="/home/dmitriano/dev/libs/boost"
./b2 -j8 cxxstd=20 install
And tried to build the following code:
#include
namespace asio = boost::asio;
awaitable read(const std::string& file_path)
{
print(std::format("Thread {}. read() has started.", std::this_thread::get_id()));
asio::any_io_executor exec = co_await asio::this_coro::executor;
asio::stream_file source(exec);
source.open(file_path, asio::stream_file::read_only);
co_return;
}
but got ‘asio::stream_file’ has not been declared compiler error.
There is the following condition in boost/asio/stream_file.hpp:
#if defined(BOOST_ASIO_HAS_FILE) \
|| defined(GENERATING_DOCUMENTATION)
#include
namespace boost {
namespace asio {
/// Typedef for the typical usage of a stream-oriented file.
typedef basic_stream_file<> stream_file;
} // namespace asio
} // namespace boost
#endif // defined(BOOST_ASIO_HAS_FILE)
// || defined(GENERATING_DOCUMENTATION)
#endif // BOOST_ASIO_STREAM_FILE_HPP
On Windows BOOST_ASIO_HAS_FILE is defined, but on Linux it is not. Why?
Read more here: Source link
