I currently have the following function in C:
static inline void *cmyk_to_rgb(int *dest, int *cmyk)
{
double c = cmyk[0] / 100.0;
double m = cmyk[1] / 100.0;
double y = cmyk[2] / 100.0;
double k = cmyk[3] / 100.0;
c = c * (1 - k) + k;
m = m * (1 - k) + k;
y = y * (1 - k) + k;
dest[0] = ROUND((1 - c) * 255);
dest[1] = ROUND((1 - m) * 255);
dest[2] = ROUND((1 - y) * 255);
}
When compiling, I am warned that
warning: control reaches end of non-void function [-Wreturn-type]
I've tried adding an explicit return
at the end of the function body and that results in an outright error. What is the proper way to resolve this warning? Any solutions I've found online involve adding a return statement where the function is supposed to return some value (int
etc.), but that is not the case here.
void *
is not void
Change your first line to
static inline void cmyk_to_rgb(int *dest, int *cmyk)
void *
is some pointer that isn't specified as being a particular type. Not returning a value from a function specified as returning int *
would give you a similar error.