eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.24k stars 170 forks source link

Cannot use mock with methods that are declared with _stdcall #71

Open kjstaas opened 8 years ago

kjstaas commented 8 years ago

I have an interface that has its methods all declared as __stdcall that cause compilation errors whenever I try to stub/fake them. I am using the mstest single header with Visual Studio 2015 update 3.

an example illustrating the issue. Given the following interface:

class DependencyInterface
{
public:
    ~DependencyInterface() {}
    virtual int RegularMethod(int foo, int bar) = 0;
    virtual int __stdcall StdCallMethod(int foo, int bar) = 0;
};

and the following unit test code:

When(Method(mock, RegularMethod)); // works fine
When(Method(mock, StdCallMethod)); // compile error

This will produce the following errors (there are more C2784 then I listed, looks like one for each version of the stub function).

C2672
'fakeit::Mock::stub': no matching overloaded function found

C2784
'fakeit::MockingContext<void,arglist...> fakeit::Mock::stub(R (thiscall T::* )(arglist...) volatile const)': could not deduce template argument for 'R (thiscall T::* )(arglist...) volatile const' from 'int (__stdcall DependencyInterface::* )(int,int)'