Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with gtest headers during tests #230

Closed
levavakian opened this issue Aug 31, 2016 · 2 comments
Closed

Conflict with gtest headers during tests #230

levavakian opened this issue Aug 31, 2016 · 2 comments

Comments

@levavakian
Copy link

When I try to use C++ Resk SDK headers along gtest headers, I get a slew of errors in gtest that are something along the lines of this:

/usr/include/gtest/internal/gtest-internal.h:961:54: error: declaration of ‘rhs’ as array of references
inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {
                                                     ^
/usr/include/gtest/internal/gtest-internal.h: In function ‘bool testing::internal::ArrayEq(...)’:
/usr/include/gtest/internal/gtest-internal.h:962:28: error: ‘lhs’ was not declared in this scope
  return internal::ArrayEq(lhs, N, rhs);
                           ^
/usr/include/gtest/internal/gtest-internal.h:962:36: error: ‘rhs’ was not declared in this scope
  return internal::ArrayEq(lhs, N, rhs);
                                   ^
/usr/include/gtest/internal/gtest-internal.h: At global scope:
/usr/include/gtest/internal/gtest-internal.h:1001:40: error: variable or field ‘CopyArray’ declared void
inline void CopyArray(const T(&from)[N], U(*to)[N]) {
                                       ^
/usr/include/gtest/internal/gtest-internal.h:1001:23: error: expected primary-expression before ‘const’
inline void CopyArray(const T(&from)[N], U(*to)[N]) {
                      ^

which only hit if the C++ Rest SDK headers are included before the gtest headers. If I put the gtest headers at the top, then all is fine. Has anyone else encountered this?

I thought the source might be a sneaky #define somewhere, but I haven't been able to find the source yet.

@ras0219-msft
Copy link
Contributor

Yes, this is caused by us defining a macro U(X). This can be suppressed by defining _TURN_OFF_PLATFORM_STRING before including a C++REST SDK header.

https://github.com/Microsoft/cpprestsdk/blob/master/Release/include/cpprest/details/basic_types.h#L95

@levavakian
Copy link
Author

Cheers!

ohlidalp added a commit to ohlidalp/rigs-of-rods that referenced this issue Jun 18, 2019
Macro `U()` must not be defined in header - conflicts with GoogleTest, see microsoft/cpprestsdk#230 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants