What the use of (void)(a)?

C

c0ee

I don't know what the use of following macro, does anyone know it?
#define NOT_USED(a) (void )(a)

Thanks.
 
H

Hemant Mohan

This is used to prevent compile r warnings/ errors in case of unused
local parameters / variables in a function.
 
P

Peter Nilsson

Hemant said:
This is used to prevent compile r warnings/ errors in case of unused
local parameters / variables in a function.

What is? Please quote the context of the message you're replying to...

Note that warnings can be issued for _any_ reason. So, whilst the
following use of the macro may silence a warning about an unused
parameter...

void foo(int a, int b)
{
NOT_USED(a);
return b + 42;
}

....it may provoke a warning about the unused expression value in other
compilers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top