I have two structures defined like this (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);
Then I have the following in main.c that works:
hsv hsvCol = {i/255.0, 1, 1}; rgb col = hsv2rgb(hsvCol);
I want to be able to simply create the hsvCol variable inside the parameters for hsv2rgb without creating a variable and passing it as a parameter.
I tried each of the following (instead of the two lines above), unfortunately, none of them compiles :(
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:
source share