Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for empty "dbg()" calls. #64

Closed
sharkdp opened this issue Nov 15, 2019 · 6 comments
Closed

Add support for empty "dbg()" calls. #64

sharkdp opened this issue Nov 15, 2019 · 6 comments
Assignees

Comments

@sharkdp
Copy link
Owner

sharkdp commented Nov 15, 2019

The dbg-macro call includes file, line and function information anyway, so empty

dbg();

calls can be helpful as well (instead of a dummy dbg("this is executed") call).

@DerekCresswell
Copy link
Contributor

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?

@sharkdp
Copy link
Owner Author

sharkdp commented Dec 13, 2019

Sure, sounds great!

DerekCresswell added a commit to DerekCresswell/dbg-macro that referenced this issue Dec 15, 2019
dbg can now be called like dbg() with no arguments. Works by using the
VA_ARGS to determine how many arguements have been passed in via dbg_x.
Also works just fine if DBG_MACRO_DISABLE is defined.
DerekCresswell added a commit to DerekCresswell/dbg-macro that referenced this issue Dec 17, 2019
dbg can now be called like dbg() with no arguments. Works by using the
VA_ARGS to determine how many arguements have been passed in via dbg_x.
Also works just fine if DBG_MACRO_DISABLE is defined.
DerekCresswell added a commit to DerekCresswell/dbg-macro that referenced this issue Dec 17, 2019
dbg can now be called like dbg() with no arguments. Works by using the
VA_ARGS to determine how many arguements have been passed in via dbg_x.
Also works just fine if DBG_MACRO_DISABLE is defined.
@DerekCresswell
Copy link
Contributor

DerekCresswell commented Dec 24, 2019

@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
Copy link
Owner Author

sharkdp commented Dec 27, 2019

@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, google/googletest#634, google/googletest#219, google/googletest#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?

@DerekCresswell
Copy link
Contributor

DerekCresswell commented Dec 28, 2019

@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__)

sharkdp pushed a commit to DerekCresswell/dbg-macro that referenced this issue Dec 28, 2019
dbg can now be called like dbg() with no arguments. Works by using the
VA_ARGS to determine how many arguements have been passed in via dbg_x.
Also works just fine if DBG_MACRO_DISABLE is defined.
@sharkdp
Copy link
Owner Author

sharkdp commented Dec 31, 2020

Closing for now, as we now support multiple arguments (#2). Empty calls can not be supported, unfortunately.

@sharkdp sharkdp closed this as completed Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants