You can see what i'm trying to do below:
typedef struct image_bounds {
int xmin, ymin, xmax, ymax;
} image_bounds;
#define IMAGE_BOUNDS(X) ((image_bounds *)(X));
typedef struct {
image_bounds bounds;
float dummy;
} demo;
int
main(void) {
demo my_image;
/* this works fine */
((image_bounds *)(&my_image))->xmin = 10;
/* why doesn't this work? i get the following error:
/* In function main:
cast.c:20: error: expected expression before = token
*/
IMAGE_BOUNDS(&my_image)->xmin = 20;
return 0;
}
As you can see from above the C cast works but the macro version does not, what am I doing wrong?