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

Many "-Wunused-value" warnings when DBG_MACRO_DISABLE is defined #36

Closed
fgallegosalido opened this issue Jun 24, 2019 · 4 comments · Fixed by #46
Closed

Many "-Wunused-value" warnings when DBG_MACRO_DISABLE is defined #36

fgallegosalido opened this issue Jun 24, 2019 · 4 comments · Fixed by #46

Comments

@fgallegosalido
Copy link

When we use dbg() with a variable, the compilers detect an unused value, so a warning is shown. This warnings should be hidden with pragmas or some language specific syntax.

@fgallegosalido
Copy link
Author

fgallegosalido commented Jun 24, 2019

I have a hack that can do the trick;

namespace dbg_macro{
    template <typename T>
    T&& unused_(T&& t){
        return std::forward<T>(t);
    }
}
#define dbg(...) dbg_macro::unused_(__VA_ARGS__)

That can do the job, but adds some boilerplate and it's not fully tested

@Jackojc
Copy link

Jackojc commented Jun 24, 2019

Just out of curiosity, could you show some example code that produces a warning?

@fgallegosalido
Copy link
Author

Take the example.cpp file and add at the beginning #define DBG_MACRO_DISABLE

@sharkdp
Copy link
Owner

sharkdp commented Jul 2, 2019

@fgallegosalido Thank you! I took the liberty to implement your solution in #46.

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.

3 participants