Awkward interaction with Google Test

Aug 20, 2015 at 8:49 AM
Edited Aug 21, 2015 at 9:20 AM
I was getting compiler errors when I was trying to use Google Test, in very specific template methods in gtest-internal. I think this was caused by the macro U. After changing the U to V in

template <typename T, typename U, size_t N>
inline void CopyArray(const T(&from)[N], U(*to)[N])

and

template <typename T, typename U, size_t N>
inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N])

The problem was solved and I haven't had any other issues. I'm slightly confused as there are other templates using T and U that haven't required changing.


Ben

EDIT: I should mention that this was in gtest-internal.h
Aug 21, 2015 at 9:20 AM
I've take a look at the offending code again. These two methods were the only ones with U followed by brackets in the header.
Aug 21, 2015 at 8:42 PM
Yes, we provide a U() macro function to allow you to describe string literals of the platform's native string width (on windows this means UTF16, on other platforms you get UTF8).

This macro is defined in include\cpprest\details\basic_types.h and can be disabled using the macro _TURN_OFF_PLATFORM_STRING.