I'm building the project with Clang 13.0.0 and I'm using libstdc++ 6.0.25 (system default). It's hard to use libc++ due to the dependencies. According to this table, my version of libstdc++ corresponds to GCC 8.1.0, which has a limited support for c++20 features. Below is a part of my CMakeLists.txt:
cmake_minimum_required(VERSION 3.17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
project(my_project LANGUAGES CXX)
...
add_executable(my_bin ...)
...
target_link_libraries(my_bin PRIVATE ... lstdc++ ...)
There is a feature-testing macro in one of the third-party libraries (gtest):
#ifdef __cpp_char8_t
...
#endif
And for some reason I end up with this macro enabled, though, according to this table char8t is only available since GCC 9. And after all the compilation fails. As far as I know, there is no way to 'undef' macro in make/cmake. Is there any idea how to get it working? Or, is it totally wrong to use clang 13 with an older libstdc++?
Update (the example of the code that fails, as requested in comments):
#ifdef __cpp_char8_t
GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char8_t, ::std::u8string); //<-- ln389
GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char8_t, ::std::u8string);
#endif
The following error occurs:
tools/google-test-1.11/googletest/include/gtest/gtest-printers.h:389:55:
error: no member named 'u8string' in namespace 'std'
Update 2: Thank you Barry for pointing this out, indeed, the problem is in that __cpp_char8_t macro is insufficient for std::u8string (__cpp_lib_char8_t should be used for this), and it is clearly a bug in the gtest library. Sorry for not providing this from the start, my bad. Somehow I thought that gtest code shouldn't be wrong + didn't read the error message good enough.