Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Build break in gmock and gmock_test projects (Windows) #188

Open
chrsmith opened this issue Nov 25, 2015 · 5 comments
Open

Build break in gmock and gmock_test projects (Windows) #188

chrsmith opened this issue Nov 25, 2015 · 5 comments

Comments

@chrsmith
Copy link

This was an error reported by someone on the old Google Code project. I'm reporting it here so that it doesn't get forgotten in the Google Code turndown.


Today I downloaded the most recent code from GitHub and I am still running into the same build issues.

If possible please fix the first one and publish. Secondly I really need your help on the second one.

  1.  First the file included in gmock solution “gtest-all.cc” could not be found because it was still pointing to the old gtest folder. Fix: I removed the file and then added “existing” from the correct location and it compiled.
    
  2.  Now compiling gmock_test project, I am getting the following errors which need to be fixed. Please let me know what the fix is and I can include it. I am thinking that this is only the Unit Test project but it would still be nice to get it resolved. Thanks.
    
3)  1>------ Rebuild All started: Project: gmock, Configuration: Debug Win32 ------
4)  1>  gmock-all.cc
5)  1>  gtest-all.cc
6)  1>  Generating Code...
7)  1>  gmock.vcxproj -> C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\msvc\2010\Debug\gmock.lib
8)  2>------ Rebuild All started: Project: gmock_main, Configuration: Debug Win32 ------
9)  2>  gmock_main.cc
10) 2>  gmock_main.vcxproj -> C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\msvc\2010\Debug\gmock_main.lib
11) 3>------ Rebuild All started: Project: gmock_test, Configuration: Debug Win32 ------
12) 3>  gmock_all_test.cc
13) 3>C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\include\gmock/gmock-matchers.h(555): error C2440: 'return': cannot convert from 'const testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>' to 'testing::Matcher<testing::gmock_matchers_test::ConvertibleFromAny>'
14) 3>  C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\include\gmock/gmock-matchers.h(555): note: No constructor could take the source type, or constructor overload resolution was ambiguous
15) 3>  C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\include\gmock/gmock-matchers.h(546): note: while compiling class template member function 'testing::Matcher<testing::gmock_matchers_test::ConvertibleFromAny> testing::internal::MatcherCastImpl<T,M>::CastImpl(const M &,testing::internal::BooleanConstant<true>)'
16) 3>          with
17) 3>          [
18) 3>              T=testing::gmock_matchers_test::ConvertibleFromAny,
19) 3>              M=testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>
20) 3>          ]
21) 3>  C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\include\gmock/gmock-matchers.h(534): note: see reference to function template instantiation 'testing::Matcher<testing::gmock_matchers_test::ConvertibleFromAny> testing::internal::MatcherCastImpl<T,M>::CastImpl(const M &,testing::internal::BooleanConstant<true>)' being compiled
22) 3>          with
23) 3>          [
24) 3>              T=testing::gmock_matchers_test::ConvertibleFromAny,
25) 3>              M=testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>
26) 3>          ]
27) 3>  C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\include\gmock/gmock-matchers.h(611): note: see reference to class template instantiation 'testing::internal::MatcherCastImpl<T,M>' being compiled
28) 3>          with
29) 3>          [
30) 3>              T=testing::gmock_matchers_test::ConvertibleFromAny,
31) 3>              M=testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>
32) 3>          ]
33) 3>  C:\Users\users_name\Source\Repos\MockAndUnitTestFrameworks\googletest-master\googlemock\test/gmock-matchers_test.cc(638): note: see reference to function template instantiation 'testing::Matcher<testing::gmock_matchers_test::ConvertibleFromAny> testing::MatcherCast<testing::gmock_matchers_test::ConvertibleFromAny,testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>>(const M &)' being compiled
34) 3>          with
35) 3>          [
36) 3>              M=testing::internal::EqMatcher<testing::gmock_matchers_test::ConvertibleFromAny>
37) 3>          ]
38)   ========== Rebuild All: 2 succeeded, 1 failed, 0 skipped ==========
@itsrp4u
Copy link

itsrp4u commented Jan 18, 2016

I have got the same error mentioned in the 2nd point by chrsmith above while compiling googlemock release 1.7.0 version on Visual Studio 2015. Any one has a solution for this? Any help is greatly appreciated !!

Error C2440 'return': cannot convert from 'testing::internal::EqMatchertesting::gmock_matchers_test::ConvertibleFromAny' to 'testing::Matchertesting::gmock_matchers_test::ConvertibleFromAny' gmock_test

Both gmock and gmcok_main projects compile successfully on VS 2015 after a minor change in gmock_config.props. The error occurs when we compile gmock_test on VS 2015.

@Flow86
Copy link

Flow86 commented Jan 20, 2016

got the same problem, any solution?

@irwand
Copy link

irwand commented Jan 21, 2016

I tried debugging this a bit. I think it's because somehow the compiler finds another path from 'const testing::internal::EqMatchertesting::gmock_matchers_test::ConvertibleFromAny' to 'testing::Matchertesting::gmock_matchers_test::ConvertibleFromAny'

Looking at the code it should have implicitly called 'template EqMatcher::operator Matcher() const', inherited from ComparisonBase class. I'm not sure what other things that the compiler sees that makes it ambiguous?

Matcher can implicitly be constructed from T (T is ConvertibleFromAny in this case). But there's nothing that can implicitly go from 'const EqMatcher' to 'ConvertibleFromAny'. Besides, there's that interesting comment right above the line with error:
// Even if T has an implicit constructor from M, it won't be called because
// creating Matcher would require a chain of two user-defined conversions
// (first to create T from M and then to create Matcher from T).

I'm stumped. This could be a compiler bug. Hopefully the above could help investigate this issue further.

@sean-wang-wenfeng
Copy link

I got the same problem when I tried to guild the gmock test in the VS2015 IDE.

@roman-v-l
Copy link

I fixed this error by making the template constructor in ConvertibleFromAny explicit:

explicit ConvertibleFromAny(const T& /a_value/) : value(-1) {
ADD_FAILURE() << "Conversion constructor called";
}

After that I got an error here:

TEST(EqTest, CanDescribeSelf) {
Matcher m = Eq(Unprintable());
EXPECT_EQ("is equal to 1-byte object <61>", Describe(m));
}

In order to fix it, I made the member "operator==" in class Unprintable a non-member function:

class Unprintable {
public:
    Unprintable() : c_('a') {}

private:
    char c_;
};

bool operator==(const Unprintable&,  const Unprintable&) { return true; }

Now I can build gmock_test with no errors and all the tests are passed when I run it.

KindDragon added a commit to KindDragon/googletest that referenced this issue Feb 23, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue Mar 6, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue May 12, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue Jun 24, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue Jun 27, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue Jun 29, 2016
KindDragon added a commit to KindDragon/googletest that referenced this issue Jul 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants