What's the purpose of (void)client_data ?? It's already being passed in as a void pointer....Code:data_free(void *event_data, void *client_data) { (void) client_data; free(event_data); }
What's the purpose of (void)client_data ?? It's already being passed in as a void pointer....Code:data_free(void *event_data, void *client_data) { (void) client_data; free(event_data); }
I'd say that it is used to avoid a compiler warning about client_data not being used. However, there are much simpler and beautiful approaches to that...
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
>99% of what I see is simply the commenting out of the parameter name.
Which only works in C++. In C it's a syntax error to have an unnamed parameter in a function definition.
My best code is written with the delete key.
I just let the argument name out. In the case I want to keep it in anyway, I define a macro:
Then I would do:Code:#define UNUSED(x)
I think that's also what Qt4 does.Code:data_free(void *event_data, void * UNUSED(client_data))
However:
I see that, I didn't know it! So it seems that it really is one of the most standard ways of doing it. Other than the classical x = x;>99% of what I see is simply the commenting out of the parameter name.
Which only works in C++. In C it's a syntax error to have an unnamed parameter in a function definition.
Maybe it could be cleaner with a macro...maybe not!
Also, *without* optimization, doesn't the void method produce a nop?
>Also, *without* optimization, doesn't the void method produce a nop?
It should produce a no-op regardless (though an exceptionally poor compiler may not do so). The cast simply silences a potential warning.
My best code is written with the delete key.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"