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

Proposal: get rid of warning on unused parameters #5

Open
diggit opened this issue Sep 1, 2018 · 3 comments
Open

Proposal: get rid of warning on unused parameters #5

diggit opened this issue Sep 1, 2018 · 3 comments

Comments

@diggit
Copy link
Contributor

diggit commented Sep 1, 2018

Hi,
-Wunused and for me -Wunused-parameter is sometimes very handy.

As title says, it would be nice to have such warnings suppressed on functions, that intentionally not use some parameter.

Possible solutions are explained here on SO.

If you want this solved, which solution do you prefer?

@flit
Copy link
Owner

flit commented Sep 2, 2018

Yeah, that's a good idea. I normally have that warning turned off, but I'd be happy to address it.

My preference is the unused attribute via a macro, like the attribute macros at the top of ar_internal.h:

#if !defined(UNUSED)
#define UNUSED __attribute__((unused))
#endif

This, of course, can be used in a function definition:

void some_function(int x, UNUSED int y)
{
    return x;
}

And it provides an opportunity to customize or set to empty based on the compiler.

I'm not a fan of the (void)x; style, as long as the unused attribute is available.

Thanks!

@diggit
Copy link
Contributor Author

diggit commented Sep 3, 2018

Ok, I can fix that, but where to put this macro?
One unused parameter is width in classes.h:602 which does not include ar_internal.h (of course, it's public include)
Another case is object2 in ar_mutex.cpp:15 which ar_internal.h includes...

GCC and armcc support __attribute__((unused)), not sure about IAR.

@flit
Copy link
Owner

flit commented Sep 10, 2018

The unused width parameter on the Channel ctor looks like a bug, actually. It will even cause TypedChannel to not work correctly for any type that is not the same size as void *. Thanks for finding this! 😀

So, probably the best place for an UNUSED macro is at the top of ar_internal.h, next to the other attribute macros.

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

No branches or pull requests

2 participants