Fix some functions when using cgreen with its namespace in C++.#325
Fix some functions when using cgreen with its namespace in C++.#325thoni56 merged 1 commit intocgreen-devs:masterfrom
Conversation
|
Sorry, for the belated reply here. Thanks for this, I think this looks good, but as I'm not fully fluent in all the ins and outs of C++ that's more of an amatuers opinion.
You shouldn't be so confident in earlier decisions ;-) Have you tried making that change? Perhaps @matthargett has some input on that "decision"? |
|
There were two main rules, but @strtok or @lastcraft might remember more:
I think this PR works, but maybe we could use a __CGREEN_NAMESPACE_PREFIX macro that's defined to empty for non-C++ so that we don't need to duplicate all the definitions for each language? I realize we may not have done that consistently when we first did the work 16 years ago, but that's my only minor suggestion with older (never wiser ;) ) eyes. If there's any contention about using a macro to help prefix the namespace, feel free to merge as-is. |
|
Hi, Just to clarify there are no "using" statements in the patch and I concur that "No using statements in header files." is a good rule to live by. What I meant by the statement,
is that anyone who did use As for the macro solution, I agree that that is a much cleaner and more elegant solution since it wouldn't require copying and pasting like I did with mine. Where would that macro best be defined? Edit: Unquoted "is that anyone who did ..." bit sentence. |
|
Using a macro to make the definitions only occur once seems cool and practical at first. But thinking a bit more, I realized that having a simple #define will not work because we cannot do
since that will become a whole different identifier. And inserting a space
will not work as AFAIK you are not allowed to have a space between the An option would be to create a more complex macro, something like But it feels this will takes away a lot of the readability of these declarations. So it comes down to, as it often does, readability or terseness/DRY. I hope someone can either correct me or come up with a better solution because we have the same thing in |
|
I was ill informed and the Thanks @TommyJC ! |
Hello,
Using cgreen for C++ without including
using namespace cgreenin the code results in compilation errors when one attempts to usecgreen::assert_that().I just prefixed some things with
cgreen::and addednamespace cgreen {where appropriate.The changes from this patch fixed the parts of cgreen I utilized but I haven't been able to test everything in cgreen.
Ideally I wanted to add the cgreen namespace to
TestSuiteininclude/cgreen/internal/suite_internal.has well but since that hasnamespace cgreen {later, I take it there was a good reason not to add TestSuite to the cgreen namespace.Those who are applying
using namespace cgreento get around the compilation error should see no difference.