Closed sharkdp closed 3 years ago
Hello. This seems like something suitable for someone new to this repo. I'd be happy to take this on as a stepping stone. :) Want to assign it to me?
Sure, sounds great!
@sharkdp It seems to be basically impossible to have array initialisation AND multiple arguments (#2 ).
Because the preprocessor just sees the commas as new arguments we can't have this work with more than one argument.
What does work :
std::vector<int> arr = {1,0}; dbg(arr);
dbg((std::vector<int>{0,1}));
(Though it does print the extra brackets)
Simply because this uses macros I don't think if we can get around this. But using templates more limits the ability to return multiple arguments like my implementation can. Seeing as it is still possible to do these do you think is it worth the sacrifice?
Another alternate is to simply make a seperate dbg_arr
macro.
@sharkdp It seems to be basically impossible to have array initialisation AND multiple arguments (#2 ). Because the preprocessor just sees the commas as new arguments we can't have this work with more than one argument.
I think you are right. There is a similar limitation in gtest
(see e.g. https://stackoverflow.com/q/44459921/704831, https://github.com/google/googletest/issues/634, https://github.com/google/googletest/issues/219, https://github.com/google/googletest/issues/733).
It's not just initializer lists, but also comma-separated template arguments (Foo<int, 10>
) or unparenthesized comma-operators within lambda functions.
Simply because this uses macros I don't think if we can get around this.
I also think so.
Seeing as it is still possible to do these do you think is it worth the sacrifice?
I believe I would rather give up multiple-argument support. I will close #2 and refer to this thread.
How do we proceed with this PR? Do you think that we should still implement the empty-argument macro call?
@sharkdp #67 can be pulled. The empty calls have no issue with any commas.
Sad that comma seperated args has fallen away. At least we can have these.
Though at the current moment seems like the tests don't like my most recent commit. I'm not used to Appveyor, perhaps you can enlighten me on what's wrong. My only thought is that since it's a windows enviroment it does not like the (, ##__VA_ARGS__)
Closing for now, as we now support multiple arguments (#2). Empty calls can not be supported, unfortunately.
The
dbg-macro
call includes file, line and function information anyway, so emptycalls can be helpful as well (instead of a dummy
dbg("this is executed")
call).