Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of (apparently) empty C function

Tags:

c

void

Can anyone comment on the point of the following function, which appears to do not very much:

// Returns stored values
int getDetails(const int param1[],
               int* param2,
               int* param3,
               int* param4)
{
    (void)param1;
    (void)param2;
    (void)param3;
    (void)param4;
    return 0;
}

The comment is actually there with the code. I'm thinking it must be some kind of odd stub but it is being called and I'm racking my brains to try to imagine what I'm missing.

My best hunch so far is that the function has been deprecated but not removed and the (void)param is to avoid compiler warnings about unused variables.

like image 737
Component 10 Avatar asked Jun 10 '26 17:06

Component 10


1 Answers

Statements like (void)param1; are typically used to suppress warnings about unused function parameters. (As an aside, in C++ you could also comment out or remove the parameter names.)

You're correct that the function does nothing. If other code doesn't create a pointer to it, you could safely remove it.

like image 188
simonc Avatar answered Jun 13 '26 16:06

simonc