|
From: Allin C. <cot...@wf...> - 2013-07-25 08:41:55
|
On Wed, 24 Jul 2013, sfeam (Ethan Merritt) wrote: > 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] Yes, indeed. > 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. My patches also change the return type of the relevant callback functions to INT_PTR for win64. However, given how broken the MS design is, I'd be happy to leave things as they were (in respect of CreateDialogParam) and put up with the warnings from gcc. If it might be useful I can submit an alternative version of the patch-set. Allin Cottrell |