trompeloeil
trompeloeil copied to clipboard
Can't mock a method taking as parameter a type with the same name than the function
I tried to mock a method with this signature: void reply(reply)
and the compiler complained with:
error: invalid use of non-static member function
9 | TROMPELOEIL_MAKE_MOCK1(reply, void(reply));
| ^~~~~
So it thinks that the type name is actually the method again.
For better or worse AFAIK the method signature is valid, so it would be good if trompeloeil
could mock such a case.
Wow, this is interesting. I agree that it's desirable that it should work, but I have no idea at all about how to make it work. The macro expands to an implementation of the function, and in that function body, the name refers to the function itself and not the type.
It's reasonably easy to work around, though, by being explicit about the name of the type.
https://gcc.godbolt.org/z/jnLh5v