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

Macros require using namespace fakeit; #95

Open j-mok opened 7 years ago

j-mok commented 7 years ago

Without using namespace fakeit; macros like When and Verify won't compile. I believe this is due to these macros not expanding to namespace-qualified identifiers in api_macros.hpp Correct me if I'm wrong.

For example defining When like this: #define When(call) \ ::fakeit::When(call)

would help with the issue.

j2bbayle commented 7 years ago

What compiler do you use? It works fine for me with the latest clang...

j-mok commented 7 years ago

I'm no longer using FakeIt, but when I was I compiled it with MSVC 2013. I'm wondering how come clang be able to resolve unqualified When to ::fakeit::When? Are you sure you don't have a using namespace fakeit; or an alias for When somewhere in scope?

j2bbayle commented 7 years ago

My message was not clear enough: with using namespace fakeit, or defining new macros like you the one you showed in your first message do work. But then I don't really see the issue here: putting the checking macros in the fakeit namespace sounds like a sensible design choice.

j-mok commented 7 years ago

OK, so now I'm confused, but let's reiterate in points:

Does that sound reasonable?

j2bbayle commented 7 years ago

Ok, I now see what you mean. Sorry I was totally off. It does sound reasonable indeed!