【发布时间】:2021-04-29 09:00:22
【问题描述】:
我正在使用 googlegtest 进行测试,但在编译时出现错误。
/gtest-printers.h:389:55: error: no member named 'u8string' in namespace 'std' GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char8_t, ::std::u8string);
/home/googletest/googletest/include/gtest/gtest-printers.h:379:40: note: expanded from macro 'GTEST_IMPL_FORMAT_C_STRING_AS_STRING_' class FormatForComparison<CharType*, OtherStringType> {
/home/googletest/googletest/include/gtest/gtest-printers.h:390:61: error: no member named 'u8string' in namespace 'std' GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char8_t, ::std::u8string);
/home/googletest/googletest/include/gtest/gtest-printers.h:379:40: note: expanded from macro 'GTEST_IMPL_FORMAT_C_STRING_AS_STRING_' class FormatForComparison<CharType*, OtherStringType> {
生成了 2 个错误。`
这是宏的参数。
编译器版本:Clang++ 11.1.0
在 googletest 内编译可以工作,但是当包含为标头时,编译失败。无法找到错误的根本原因?
您能帮忙说明为什么链接会发生在 std 上吗?
make VERBOSE=1 输出:
【问题讨论】:
-
您是否在启用 C++20 模式的情况下进行构建?
std::u8string是 C++20 标准中的新功能,在 Clang 11 中可能默认未启用。 -
设置 CXX_FLAGS=-std=c++20 后没有运气
-
尝试
make VERBOSE=1并粘贴输出消息将有助于找到根本原因。 -
我附上了详细输出的链接
-
@TheShmoo 尝试安装 sudo apt install libstdc++-11-dev libstdc++-11-doc