My actual code (class name changed, some cut, as it is company confidential, but there is only one compiler error, so what I cut should not be affecting things)
class Xyz
{
public:
virtual void vPrintStatus() const;
};
and its mock
class MockXyz : public Xyz
{
public:
MOCK_CONST_METHOD0(vPrintStatus,
void());
};
Which gives me a compiler error : error: ‘vPrintStatus’ is not a type
#includes, etc are OK. The compiler is obviously finding vPrintStatus
, as, if I change it to something undefined:
MOCK_CONST_METHOD0(independence,
void());
I get error: ‘independence’ has not been declared
.
So, the compiler finds vPrintStatus
and appears to know its type (or, at least, what type it is not).
I am sure that I am following the syntax for MOCK_CONST_METHOD0
- the mock macro shoudl be expecting a function name, not a type, as its first parameter.
What am I doing wrong?
The below error message:
error: ‘vPrintStatus’ is not a type
indicates that MOCK_CONST_METHOD0(vPrintStatus, void());
was parsed by a compiler as a declaration of a member function, named MOCK_CONST_METHOD0
, taking two parameters, one of type vPrintStatus
(hence the error), and another being a function pointer type (void(*)()
after adjustment). Clearly, this means that the definition of macro MOCK_CONST_METHOD0
is not visible to the translation unit the mock declaration is part of. Make sure you have included <gmock/gmock.h>
to that file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With