From e66d103cdccd226998723ae3e15320a4338dc0b2 Mon Sep 17 00:00:00 2001 From: Idar Tollefsen Date: Mon, 9 Jan 2017 12:53:47 +0100 Subject: [PATCH] Adds BOOST_HAS_UNISTD_H check for unistd.h inclusion. Given a configuration file used with -DBOOST_USER_CONFIG such as: --- #define BOOST_NO_CONFIG #define BOOST_BIND_NO_PLACEHOLDERS #define BOOST_DISABLE_ABI_HEADERS #define BOOST_COMPILER_CONFIG "boost/config/compiler/clang.hpp" #define BOOST_STDLIB_CONFIG "boost/config/stdlib/libcpp.hpp" #define BOOST_PLATFORM "linux" #define BOOST_HAS_UNISTD_H --- Then ASIO will, in detail/config.hpp, include and and define BOOST_ASIO_HAS_BOOST_CONFIG. Further down in the same file, BOOST_ASIO_HAS_UNISTD_H decides whether it should include unistd.h or not. The checks performed there fails to account for situations such as this where BOOST_ASIO_HAS_BOOST_CONFIG has been defined. In these cases, it should check whether BOOST_HAS_UNISTD_H has been defined and if so also define BOOST_ASIO_HAS_UNISTD_H so that unistd.h gets included. This probably works "as is" for the more popular combinations since they will pull in unistd.h through other configuration files (stdlib for example), but does not work for combinations that don't do that, such as Clang using libc++ on Linux. --- include/boost/asio/detail/config.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/asio/detail/config.hpp b/include/boost/asio/detail/config.hpp index 319f94fe38..f4f35e5848 100644 --- a/include/boost/asio/detail/config.hpp +++ b/include/boost/asio/detail/config.hpp @@ -641,6 +641,8 @@ || defined(__linux__) # define BOOST_ASIO_HAS_UNISTD_H 1 # endif +# elif defined(BOOST_HAS_UNISTD_H) +# define BOOST_ASIO_HAS_UNISTD_H 1 # endif // !defined(BOOST_ASIO_HAS_BOOST_CONFIG) #endif // !defined(BOOST_ASIO_HAS_UNISTD_H) #if defined(BOOST_ASIO_HAS_UNISTD_H) -- 2.10.1