I have two structs defined as so (in color.h
):
typedef struct rgb {
uint8_t r, g, b;
} rgb;
typedef struct hsv {
float h, s, v;
} hsv;
hsv rgb2hsv(rgb color);
rgb hsv2rgb(hsv color);
I then have the following in main.c
which works:
hsv hsvCol = {i/255.0, 1, 1};
rgb col = hsv2rgb(hsvCol);
I want to be able to just create the variable hsvCol
inside the parameters for hsv2rgb
without having to create the variable and passing it as a parameter.
I've tried the each of the following (in place of the two lines above), sadly none of which compile :(
rgb col = hsv2rgb({i/255.0, 1, 1});
rgb col = hsv2rgb(hsv {i/255.0, 1, 1});
rgb col = hsv2rgb(hsv hsvCol {i/255.0, 1, 1})
rgb col = hsv2rgb(struct hsv {i/255.0, 1, 1});
My question is:
Can I do what I was trying to do at all (but obviously in a different way)?
If 1, how do I go about doing so?
rgb col = hsv2rgb((hsv){i/255.0, 1, 1});
– Wittenburg