1

I'm using googlegtest for testing but when compiling I'm getting below error.

/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 errors generated.`

It's argument for a macro.

Compiler Version : Clang++ 11.1.0

Compiling inside googletest works but when included as header, compilation fails. Couldn't root cause reason for error?

Can you help why is linking happening to std?

make VERBOSE=1 output:

VERBOSE Output

Genie
  • 117
  • 2
  • 7

1 Answers1

1

It turned out to be a gtest bug: wrong feature check macro is used in gtest-printers.h. As a temporary workaround, you can just edit the header, replacing cpp_char8_t for __cpp_lib_char8_t in a few places:

#ifdef cpp_char8_t // <---- should be changed to __cpp_lib_char8_t
//...std::u8string usage...
#endif
Anton Pilyak
  • 1,050
  • 2
  • 15
  • 34