diff --git a/.travis.yml b/.travis.yml index b7165c0..93fa51a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -111,6 +111,15 @@ matrix: sources: - ubuntu-toolchain-r-test + - os: linux + env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + - os: linux env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03 addons: @@ -147,6 +156,50 @@ matrix: sources: - ubuntu-toolchain-r-test + - os: linux + dist: trusty + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++03 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + dist: trusty + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++11 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + dist: trusty + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++14 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + dist: trusty + compiler: g++-7 + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + - os: linux env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 @@ -273,6 +326,50 @@ matrix: - ubuntu-toolchain-r-test - llvm-toolchain-precise-3.9 + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++03 + addons: + apt: + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++11 + addons: + apt: + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++14 + addons: + apt: + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + + - os: linux + compiler: clang++-4.0 + env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++1z + addons: + apt: + packages: + - clang-4.0 + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-4.0 + - os: osx env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03 diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 1ddb471..0d64b2b 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -262,6 +262,49 @@ namespace boost return std_cat_; } +#else + + // to maintain ABI compatibility between 03 and 11, + // define a class with the same layout + + private: + + class std_category + { + private: + + boost::system::error_category const * pc_; + + public: + + explicit std_category( boost::system::error_category const * pc ): pc_( pc ) + { + } + + virtual ~std_category() {} + + virtual const char * name() const BOOST_NOEXCEPT + { + return pc_->name(); + } + + // we can't define message, because (1) it returns an std::string, + // which can be different between 03 and 11, and (2) on mingw, there + // are actually two `message` functions, not one, so it doesn't work + // even if we do + + // neither can we define default_error_condition or equivalent + + // if these functions are called, it will crash, but that's still + // better than the alternative of having the class layout change + }; + + std_category std_cat_; + + public: + + error_category() BOOST_SYSTEM_NOEXCEPT: std_cat_( this ) {} + #endif public: diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d3ba574..77e7ca6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,7 +20,42 @@ project : shared:BOOST_SYSTEM_DYN_LINK=1 static:BOOST_SYSTEM_STATIC_LINK=1 ; - + + rule cxx03 ( properties * ) + { + local result ; + + if gcc in $(properties) || clang in $(properties) + { + result = -std=c++03 ; + } + else + { + result = no ; + } + + return $(result) ; + } + + rule cxx11 ( properties * ) + { + local result ; + + if 4.6 in $(properties) + { + result = -std=c++0x ; + } + else if gcc in $(properties) || clang in $(properties) + { + result = -std=c++11 ; + } + else + { + result = no ; + } + + return $(result) ; + } test-suite "system" : [ run error_code_test.cpp @@ -32,6 +67,18 @@ project [ run error_code_test.cpp : : : shared : error_code_test_shared ] + [ run error_code_test.cpp + : : : static @cxx03 : error_code_test_03 + ] + [ run error_code_test.cpp + : : : shared @cxx03 : error_code_test_shared_03 + ] + [ run error_code_test.cpp + : : : static @cxx11 : error_code_test_11 + ] + [ run error_code_test.cpp + : : : shared @cxx11 : error_code_test_shared_11 + ] [ run error_code_user_test.cpp : : : static ] @@ -62,4 +109,16 @@ project [ run std_interop_test.cpp : : : shared : std_interop_test_shared ] + [ run std_mismatch_test.cpp + : : : static @cxx03 : std_mismatch_test_03 + ] + [ run std_mismatch_test.cpp + : : : shared @cxx03 : std_mismatch_test_shared_03 + ] + [ run std_mismatch_test.cpp + : : : static @cxx11 : std_mismatch_test_11 + ] + [ run std_mismatch_test.cpp + : : : shared @cxx11 : std_mismatch_test_shared_11 + ] ; diff --git a/test/std_mismatch_test.cpp b/test/std_mismatch_test.cpp new file mode 100644 index 0000000..37a606b --- /dev/null +++ b/test/std_mismatch_test.cpp @@ -0,0 +1,65 @@ + +// Copyright 2017 Peter Dimov. +// +// 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 library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include +#include + +#if defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) + +int main() +{ + std::cout + << "The version of the C++ standard library being used does not" + " support header so interoperation will not be tested.\n"; +} + +#else + +#include +#include +#include +#include +#include +#include + +static void test_generic_category() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + BOOST_TEST_EQ( bt.name(), st.name() ); +} + +static void test_system_category() +{ + boost::system::error_category const & bt = boost::system::system_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + BOOST_TEST_EQ( bt.name(), st.name() ); +} + +int main() +{ + std::cout + << "The version of the C++ standard library being used" + " supports header so interoperation will be tested.\n"; + + test_generic_category(); + test_system_category(); + + return boost::report_errors(); +} + +#endif