Dennis Schridde schreef: >> The changes to trunk/lib/widget/scrap.c cause a compiler error >> (comparison of int with pointer). This error will only be raised while >> compiling a Windows build. I don't have the patches but according to the >> description above I'm guessing number 003. >> >> Also the previous style of comparing those two values would result in >> comparing pointer-addresses rather than a value comparison. >> (See the typedef of HWND in windef.h). >> > Seems like this more complicated... > > scrap.c sets SDL_Window (I don't think the name is choosen very wise, btw) to > info.window, which is of type HWND... > Can we revert SDL_Window back to HWND and then compare whatever type that is > with GetClipboardOwner? Would that be the clean way of doing this? Or does MS > recommend to use that HWND.i thing instead? > The currently unmodified comparison which causes the compiler to abort is this one: ( GetClipboardOwner() != SDL_Window )
Assuming GetClipboardOwner returns HWND this is the comparison being made: ( (HWND) != (int) ) which equals: ( (struct HWND__{int i;}*HWND) != (int) ) If SDL_Window is declared as HWND however you get this: ( (struct HWND__{int i;}*HWND) != (struct HWND__{int i;}*HWND) ) So the current comparison as it is being made is wrong in all cases, because all that the current comparison does is comparing pointer addresses. This will when SDL_Window is declared as HWND always return true (!=), in the case of SDL_Windows being declared as int it is rarely false. So no, reverting SDL_Window back to HWND would not fix it on its own. You'd have to change the comparison to this ( GetClipboardOwner()->i != SDL_Window->i ). As for what MS recommends I honestly don't know, what I do know however is that this is how HWND is being declared: (see winnt.h and windef.h from the MinGW include dir) #ifdef STRICT type void *HANDLE; typedef struct HWND__{int i;} *HWND; #else type PVOID HANDLE; typedef HANDLE HWND; #endif STRICT seems to be declared almost always somehow on my system (I assume it is being defined somewhere in the MinGW include headers). However you cannot expect this to be so at all times, so I'd advise using an int in all functions working with HWNDs to prevent semantic ambiguity. Then lastly: HWND.i; will never work since HWND is defined as a pointer, making it be HWND->i;. > (I guess Christian changed this in an accident, believing that, because HWND > is defined to int on Linux (by frame.h) it would be of the same type on > Windows.) > Believing windows to follow similar standards is never a good thing in my opinion ;-) . -- Giel
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev