File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Detect used C++ Standard Library
3
+ *
4
+ * This file is compiled and run via try_run in download_test_data.cmake.
5
+ */
6
+
7
+ #include < cstdio>
8
+
9
+ // see https://en.cppreference.com/w/cpp/header/ciso646
10
+ #if __cplusplus >= 202002L
11
+ #include < version>
12
+ #else
13
+ #include < ciso646>
14
+ #endif
15
+
16
+ int main ()
17
+ {
18
+ #if defined(_LIBCPP_VERSION)
19
+ std::printf (" LLVM C++ Standard Library (libc++), _LIBCPP_VERSION=%d" , _LIBCPP_VERSION);
20
+ #elif defined(__GLIBCXX__)
21
+ std::printf (" GNU C++ Standard Library (libstdc++), __GLIBCXX__=%d" , __GLIBCXX__);
22
+ #elif defined(_MSVC_STL_VERSION)
23
+ std::printf (" Microsoft C++ Standard Library (MSVC STL), _MSVC_STL_VERSION=%d" , _MSVC_STL_VERSION);
24
+ #elif defined(_LIBCUDACXX_VERSION)
25
+ std::printf (" NVIDIA C++ Standard Library (libcudacxx), _LIBCUDACXX_VERSION=%d" , _LIBCUDACXX_VERSION);
26
+ #elif defined(EASTL_VERSION)
27
+ std::printf (" Electronic Arts Standard Template Library (EASTL), EASTL_VERSION=%d" , EASTL_VERSION);
28
+ #else
29
+ std::printf (" unknown" );
30
+ #endif
31
+ }
Original file line number Diff line number Diff line change @@ -54,3 +54,18 @@ else()
54
54
endif ()
55
55
string (REGEX REPLACE "[ ]*\n " "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT} " )
56
56
message (STATUS "Compiler: ${CXX_VERSION_RESULT} " )
57
+
58
+ # determine used C++ standard library (for debug and support purposes)
59
+ if (NOT DEFINED LIBCPP_VERSION_OUTPUT_CACHED )
60
+ try_run (RUN_RESULT_VAR COMPILE_RESULT_VAR
61
+ "${CMAKE_BINARY_DIR} " SOURCES "${CMAKE_SOURCE_DIR} /cmake/detect_libcpp_version.cpp"
62
+ RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
63
+ )
64
+ if (NOT LIBCPP_VERSION_OUTPUT )
65
+ set (LIBCPP_VERSION_OUTPUT "Unknown" )
66
+ message (AUTHOR_WARNING "Failed to compile cmake/detect_libcpp_version to detect the used C++ standard library. This does not affect the library or the test cases. Please still create an issue at https://github.com/nlohmann/json to investigate this.\n ${LIBCPP_VERSION_COMPILE_OUTPUT} " )
67
+ endif ()
68
+ set (LIBCPP_VERSION_OUTPUT_CACHED "${LIBCPP_VERSION_OUTPUT} " CACHE STRING "Detected C++ standard library version" )
69
+ endif ()
70
+
71
+ message (STATUS "C++ standard library: ${LIBCPP_VERSION_OUTPUT_CACHED} " )
Original file line number Diff line number Diff line change @@ -1914,10 +1914,12 @@ TEST_CASE("MessagePack with std::byte")
1914
1914
SECTION (" empty vector" )
1915
1915
{
1916
1916
const std::vector<std::byte> empty_data;
1917
- CHECK_THROWS_WITH_AS ([&]() {
1917
+ CHECK_THROWS_WITH_AS ([&]()
1918
+ {
1918
1919
[[maybe_unused]] auto result = json::from_msgpack (empty_data);
1919
1920
return true ;
1920
- }(),
1921
+ }
1922
+ (),
1921
1923
" [json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input" ,
1922
1924
json::parse_error&);
1923
1925
}
You can’t perform that action at this time.
0 commit comments