Reputation: 576
I'm attempting to integrate googlemock into my tests. I had already successfully built and run tests on googletest, and now am trying to incrementally add the gmock functionality into the tests as well, but I've hit a compile error that I utterly do not understand.
I am not attempting to use or define mocked classes, or use anything gmock.h provides. At the top of my (previously working) tests.cpp file I merely type
#include "gmock/gmock.h"
And I get the compile error:
gmock/gmock-matchers.h(2497) : error C2059: syntax error : 'sizeof'
gmock/gmock-matchers.h(2505) : see reference to class template instantiation 'testing::internal::ElementsAreMatcherImpl' being compiled
gmock/gmock-matchers.h(2497) : error C2059: syntax error : ')'
gmock/gmock-matchers.h(2497) : error C2143: syntax error : missing ')' before '{'
gmock/gmock-matchers.h(2497) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
gmock/gmock-matchers.h(2499) : warning C4183: 'Message': missing return type; assumed to be a member function returning 'int'
I'm compiling this using nmake/vc++ on Windows 7, and I can't fathom why I would get these compile errors simply from adding the core gmock include file to my test file. Has anyone seen this sort of thing before?
Upvotes: 9
Views: 23140
Reputation: 1
Things to make sure before using gtest and gmock.
Upvotes: 0
Reputation: 1
#include <iostream>
#include "gmock/gmock.h"
template <typename T>
class Foo : private T {
public:
void foo() {
T::bar();
}
};
class Bar {
public:
void bar() {
std::cout << "Hey there!" << std::endl;
}
};
int main() {
Foo<Bar> f;
f.foo();
}
template <typename T>
class Foo : private T {
public:
void foo() {
T::bar();
}
};
class Bar {
public:
void bar() {
std::cout << "Hey there!" << std::endl;
}
};
int main() {
Foo<Bar> f;
f.foo();
}
Upvotes: -1
Reputation: 121
If all the things above are true it should work.
Upvotes: 4