I was just going thro' source code of Yahoo's Trafic Server It is written in C++.
In almost all methods (from one of modules),
they do void(param) on each param that function receive.
(Eg below)
Can someone explain what this could be for ?
int
some_method_name(caddr_t addr, size_t len, caddr_t end,
int flags)
{
(void) end;
(void) addr;
(void) len;
(void) end;
(void) flags;
......
....
}
PS: For actual source code, please see methods from http://github.com/apache/trafficserver/blob/trunk/iocore/eventsystem/SocketManager.cc
When used as a function return type, the void keyword specifies that the function doesn't return a value. When used for a function's parameter list, void specifies that the function takes no parameters. When used in the declaration of a pointer, void specifies that the pointer is "universal."
What will happen when we use void in argument passing? Explanation: As void is not having any return value, it will not return the value to the caller.
The void data type is typically used in the definition and prototyping of functions to indicate that either nothing is being passed in and/or nothing is being returned.
It is also used as a generic pointer (e.g., void* ), although this usage is needed less often in C++ than in C. C++ does not require that void be used to indicate that there are no function parameters, but it is often used in this way for compatibility with C.
This suppresses the "unused argument" warnings. Those statements do nothing, but count as using the argument.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With