From 8c2560761b932b75b4f75112baae0e874dc46501 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 16 Sep 2020 22:16:40 +0900 Subject: [PATCH] chore: enable to use __cplusplus on MSVC related: https://github.com/ToruNiina/toml11/issues/112 --- .github/workflows/main.yml | 2 ++ CMakeLists.txt | 4 ++++ tests/test_literals.cpp | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 467c861..2069b63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -99,6 +99,7 @@ jobs: - name: Configure shell: cmd run: | + file --mime-encoding tests/test_literals.cpp mkdir build cd build cmake ../ -G "NMake Makefiles" -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DBoost_ADDITIONAL_VERSIONS=1.72.0 -DBoost_USE_MULTITHREADED=ON -DBoost_ARCHITECTURE=-x64 -DBoost_NO_BOOST_CMAKE=ON -DBOOST_ROOT=%BOOST_ROOT_1_72_0% @@ -109,6 +110,7 @@ jobs: - name: Test working-directory: ./build run: | + ./tests/test_literals --log_level=all file --mime-encoding tests/toml/tests/example.toml file --mime-encoding tests/toml/tests/fruit.toml file --mime-encoding tests/toml/tests/hard_example.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index 340ae4b..43f9fd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,10 @@ else() endif() endif() +if(MSVC) + add_definitions("/Zc:__cplusplus") +endif() + # Set some common directories include(GNUInstallDirs) set(toml11_install_cmake_dir ${CMAKE_INSTALL_LIBDIR}/cmake/toml11) diff --git a/tests/test_literals.cpp b/tests/test_literals.cpp index 5aaf928..f29a6d1 100644 --- a/tests/test_literals.cpp +++ b/tests/test_literals.cpp @@ -264,6 +264,20 @@ BOOST_AUTO_TEST_CASE(test_value_as_u8_literal) const toml::value v4 = u8R"('''foo''')"_toml; const toml::value v5 = u8R"("ひらがな")"_toml; + // XXX +#ifndef __cpp_char8_t + { + const char* l = u8R"(ひらがな)"; + BOOST_TEST_MESSAGE(l); + while(*l != '\0') + { + const int tmp(*l); + BOOST_TEST_MESSAGE(std::hex << tmp); + ++l; + } + } +#endif + BOOST_TEST(v1.is_string()); BOOST_TEST(v2.is_string()); BOOST_TEST(v3.is_string());