Am Sonntag, 26. November 2006 18:43 schrieb Giel van Schijndel:
> 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 (!=),
Why will it return true?
I thought HWND is a pointer to some blob, handled and allocated by Windows,
associated with the window? So this blob is allways at the same position for
the same window, so you can compare the pointer to it, can't you?
And actually SDL_Window is set from a SDL_WMinfo.window thingy, which actually
is a HWND, very probably handed over by Windows to SDL, being a reference for
the window. So I don't see why we can't compare it to some other HWND we get
from Windows. (Or why that should allways be true...)
--Dennis
> 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;.
That's what I meant...
> > (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 ;-) .
(The Linux definition of HWND only existed, as a workaround for some functions
using it, because they still had some Windows only (non crossplatform stuff)
in them.)
pgp2Y22b4Zc7X.pgp
Description: PGP signature
_______________________________________________ Warzone-dev mailing list [email protected] https://mail.gna.org/listinfo/warzone-dev
