Re: [OT] a couple of C macro queries
- Posted by ne1uno May 28, 2016
- 1304 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?
Also, while I'm here, is (void)status; just a way of suppressing unused errors/warnings?
Pete
-E is preprocess only $ gcc -E INVERT_Y.c
gluUnProject(pos_x, (height-y), 0.0, ... <eucode>