Sorry this is a nube question but searching the internet and forums I find no answer.
What does this construct do:
f(USBDriver * usbp)
{
(void) usbp;
...
The entire usb driver is full of similar constructs and I just can't figure what it does.
C Programming question
Moderators: RoccoMarco, lbednarz, tfAteba
Re: C Programming question
mobyfab wrote:The void typecast is for avoiding compiler warnings due to unused arguments.
But usbp is (?) just a pointer to a struct. There is really nothing being done. I must be missing something absolutely fundamental.
I apologize for the stupid questions. My C skills go back to '83 K&R C.
Re: C Programming question
jarekl wrote:mobyfab wrote:The void typecast is for avoiding compiler warnings due to unused arguments.
But usbp is (?) just a pointer to a struct. There is really nothing being done. I must be missing something absolutely fundamental.
I apologize for the stupid questions. My C skills go back to '83 K&R C.
Yes it's what I'm saying. It's just for the compiler not to complain, it does not actually do anything.
Re: C Programming question
mobyfab wrote:jarekl wrote:mobyfab wrote:The void typecast is for avoiding compiler warnings due to unused arguments.
But usbp is (?) just a pointer to a struct. There is really nothing being done. I must be missing something absolutely fundamental.
I apologize for the stupid questions. My C skills go back to '83 K&R C.
Yes it's what I'm saying. It's just for the compiler not to complain, it does not actually do anything.
Ok, no more questions after this (I hope)
Why would you put anything there at all then? Why not just /* .... */ ?
Re: C Programming question
Through a given structure, it's required that the USBDriver is passed as a parameter to that function - why is not really important. However, the function does not use the passed argument. If you wouldn't put the (void)usbp; there, the compiler would throw a warning. So it's really just to keep the compiler happy.
Most compilers have different macros of flags to suppress those warnings anyway, but this method is just universal and will work with any C compiler.
~ Tectu
Most compilers have different macros of flags to suppress those warnings anyway, but this method is just universal and will work with any C compiler.
~ Tectu
Re: C Programming question
Tectu wrote:Through a given structure, it's required that the USBDriver is passed as a parameter to that function - why is not really important. However, the function does not use the passed argument. If you wouldn't put the (void)usbp; there, the compiler would throw a warning. So it's really just to keep the compiler happy.
Most compilers have different macros of flags to suppress those warnings anyway, but this method is just universal and will work with any C compiler.
~ Tectu
Got it. Thanks.
Much Ado about nothing then. I'm sorry.