Re: [OT] a couple of C macro queries
- Posted by jimcbrown (admin) May 28, 2016
- 1270 views
petelomax said...
One for the C fans. Translating this bit of C code:
#define INVERT_Y(_y) (height-y) static int motion_cb(Ihandle *ih,int x,int y,char* status) { (void)status; if (move) { double dif_x, dif_y; int height = IupGetInt2(ih, "RASTERSIZE"); dif_x = x - pos_x; dif_y = y - pos_y; pos_x = x; pos_y = y; gluUnProject(pos_x, INVERT_Y(pos_y), 0.0,...
Should I really just replace INVERT_Y(pos_y) with (height-y)?
Is the use of pos_y a complete red herring?
I think so. I can't find any reference to the underscore having a special meaning to the preprocessor, and _y is a valid identifier in C (and to the C preprocessor itself).
Make you wonder why they didn't simply just write "height-y" in that spot in the first place... it's less typing for one.
petelomax said...
Also, while I'm here, is (void)status; just a way of suppressing unused errors/warnings?
Pete
I don't know, but that's my guess.