|
From: sfeam (E. Merritt) <eam...@gm...> - 2013-07-25 02:13:42
|
On Wednesday, 24 July 2013, Allin Cottrell wrote: > On Wed, 24 Jul 2013, sfeam (Ethan Merritt) wrote: > > > On Wednesday, 24 July 2013, Allin Cottrell wrote: > >> I have need of a 64-bit Windows build of gnuplot and I've been > >> working on cross-compiling from Linux using mingw64. I see > >> several places in current CVS where the code generates errors > >> and warnings. I'm attaching a patch-set which quells the > >> errors and warnings, but unfortunately I'm not able to test on > >> win64 at present. > > > > I can't help with evaluation of the full patch, but one set of > > changes strikes me as being wrong on the face of it: > > > > %%%%%%%%%%%%%% > > +#ifdef _WIN64 > > +INT_PTR CALLBACK PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); > > +#else > > BOOL CALLBACK PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); > > +#endif > > %%%%%%%%%%%%%% > > > > There's no way it can be correct to label a Boolean value as a pointer. > > > > The equivalent substitution occurs several places in your patch. > > I didn't check each one, but the routine PrintDlgProc really does return > > TRUE or FALSE, so I think at least in this case, if not all of them, > > the original code was correct. > > It's strange, I agree, but the original code throws a warning. > The caller, in all cases, is CreateDialogParam() and the > callback is the fourth argument, of type DLGPROC, in relation > to which the msdn doc points us to "DialogProc callback > function" > > http://msdn.microsoft.com/en-us/library/windows/desktop/ms645469%28v=vs.85%29.aspx > > where we find: > > <quote> > Return value > > Type: INT_PTR > > Typically, the dialog box procedure should return TRUE if it > processed the message, and FALSE if it did not. If the dialog > box procedure returns FALSE, the dialog manager performs the > default dialog operation in response to the message. > </quote> [shudder] Nevertheless, wouldn't your change just shift the site of the error/warning message? Now the prototype says it returns INT_PTR but the function itself still says it returns BOOL. So there is still a mismatch in types. I found a hideous example on that Microsoft site you linked to: http://msdn.microsoft.com/en-us/library/windows/desktop/ff728900(v=vs.85).aspx It declares a callback function INT_PTR CALLBACK OpenUrlDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) which exits with return (INT_PTR)FALSE; I guess it's a matter of "choose your poison". Ethan > It's probably OK to leave the code as is and ignore the > warning, but here it is: > > ../src/win/wgraph.c: In function 'LineStyle': > ../src/win/wgraph.c:3607:2: warning: passing argument 4 of > 'DialogBoxParamA' from incompatible pointer type [enabled by > default] > /opt/win64/lib/gcc/x86_64-w64-mingw32/4.6.4/../../../../x86_64-w64-mingw32/include/winuser.h:2104:29: > note: expected 'DLGPROC' but argument is of type 'BOOL > (*)(struct HWND__ *, UINT, WPARAM, LPARAM)' > > Allin Cottrell > |