On Wed, 2012-08-29 at 20:57 -0500, Yaakov (Cygwin/X) wrote: > On Fri, 2012-06-01 at 02:45 -0500, Yaakov (Cygwin/X) wrote: > > The attached draft patch fixes most of the issues with the build. (I > > just added the necessary mingw64-i686-* libraries to Ports.) ntdll.h > > needs some more work though; perhaps JonY could provide some input? > > Revised patches for mingw-w64-headers SVN HEAD attached.
Pending those changes, revised patch for setup attached. Tested with i686-pc-mingw32 and i686-w64-mingw32, as well as compile-only with x86_64-w64-mingw32 (autoload.c still needs changes for x64, as do other things when we get to that point). Yaakov
2012-08-30 Yaakov Selkowitz <yselkowitz@...> Fix build with mingw-w64 headers and start on X86-64 compatibility. * archive_tar.cc (archive_tar::next_file_name): Fix sscanf formats for 64-bit size_t. * autoload.c: Define DECLSPEC_IMPORT for mingw-w64 headers. * bootstrap.sh: Use i686-w64-mingw32 toolchain if available. * choose.cc (ChooserPage::OnMouseWheel): Fix return type. * choose.h (ChooserPage::OnMouseWheel): Ditto. * filemanip.cc (nt_wfopen): Fix argument cast for _open_osfhandle. * filemanip.h: Include <sys/types.h> to fix missing mode_t typedef error with mingw-w64 headers. * gpg-packet.cc: Include "win32.h" to avoid macro redefinition errors with mingw-w64 headers. (ARRAYSIZE): Do not redefine. * main.cc: Remove CINTERFACE define. (_argv): Declare if using mingw-w64 headers. (main_display): Use C++ syntax for COM. (WinMain): Move up _argv definition to before it is first used. * mklink2.cc: Remove CINTERFACE define. (make_link_2): Use C++ syntax for COM. * netio.cc (auth_proc): Fix return type. * ntdll.h: Include PSDK headers with mingw-w64 instead of DDK. * package_message.h: Include "win32.h" instead of <windows.h>. * proppage.cc (PropertyPage::FirstDialogProcReflector): Fix return type. Use SetWindowLongPtr and DWLP_* instead of SetWindowLong and DWL_*. (PropertyPage::DialogProcReflector): Ditto. (PropertyPage::DialogProc): Ditto. (PropertyPage::OnMouseWheel): Ditto. * proppage.h (PropertyPage::FirstDialogProcReflector): Fix return type. (PropertyPage::DialogProcReflector): Ditto. (PropertyPage::DialogProc): Ditto. (PropertyPage::OnMouseWheel): Ditto. * propsheet.cc (PROPSHEETHEADER_V1_SIZE): Do not redefine. * site.cc (drop_proc): Fix return type. * win32.h: Include <sys/types.h> Define DECLSPEC_IMPORT for mingw-w64 headers. * window.cc (Window::FirstWindowProcReflector): Use GWLP_* with SetWindowLongPtr calls. (Window::WindowProcReflector): Ditto. Index: archive_tar.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/archive_tar.cc,v retrieving revision 2.17 diff -u -p -r2.17 archive_tar.cc --- archive_tar.cc 8 Mar 2012 09:20:03 -0000 2.17 +++ archive_tar.cc 30 Aug 2012 09:01:53 -0000 @@ -171,7 +171,7 @@ archive_tar::next_file_name () else if (state.have_longname) state.have_longname = 0; - sscanf (state.tar_header.size, "%o", &state.file_length); + sscanf (state.tar_header.size, "%Io", &state.file_length); state.file_offset = 0; // vp2 (_tar_vfile, "%c %9d %s\n", state.tar_header.typeflag, @@ -190,7 +190,7 @@ archive_tar::next_file_name () MAX_PATH); err++; state.parent->read (&state.tar_header, 512); - sscanf (state.tar_header.size, "%o", &state.file_length); + sscanf (state.tar_header.size, "%Io", &state.file_length); state.file_offset = 0; skip_file (); return next_file_name (); Index: autoload.c =================================================================== RCS file: /cvs/cygwin-apps/setup/autoload.c,v retrieving revision 2.9 diff -u -p -r2.9 autoload.c --- autoload.c 17 Mar 2010 17:51:18 -0000 2.9 +++ autoload.c 30 Aug 2012 09:01:53 -0000 @@ -17,6 +17,7 @@ static const char *cvsid = "\n%%% $Id: a #endif #define WIN32_LEAN_AND_MEAN +#define DECLSPEC_IMPORT #include <windows.h> typedef struct { Index: bootstrap.sh =================================================================== RCS file: /cvs/cygwin-apps/setup/bootstrap.sh,v retrieving revision 2.6 diff -u -p -r2.6 bootstrap.sh --- bootstrap.sh 24 Feb 2012 20:21:42 -0000 2.6 +++ bootstrap.sh 30 Aug 2012 09:01:53 -0000 @@ -50,14 +50,22 @@ fi cd "$builddir" build=`$srcdir/cfgaux/config.guess` -host="i686-pc-mingw32" -if hash $host-g++ 2> /dev/null; then +if hash i686-w64-mingw32-g++ 2> /dev/null; then + host=i686-w64-mingw32 CC="$host-gcc" CXX="$host-g++" -else +elif hash i686-pc-mingw32-g++ 2> /dev/null; then + host=i686-pc-mingw32 + CC="$host-gcc" + CXX="$host-g++" +elif hash g++-3 2> /dev/null; then + host=i686-pc-mingw32 CC="gcc-3 -mno-cygwin" CXX="g++-3 -mno-cygwin" +else + echo "mingw32-target g++ required for building setup" + exit 1 fi echo "running configure" Index: choose.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/choose.cc,v retrieving revision 2.161 diff -u -p -r2.161 choose.cc --- choose.cc 22 Dec 2011 17:54:26 -0000 2.161 +++ choose.cc 30 Aug 2012 09:01:53 -0000 @@ -436,7 +436,7 @@ ChooserPage::OnMessageCmd (int id, HWND return true; } -BOOL CALLBACK +INT_PTR CALLBACK ChooserPage::OnMouseWheel (UINT message, WPARAM wParam, LPARAM lParam) { return chooser->WindowProc (message, wParam, lParam); Index: choose.h =================================================================== RCS file: /cvs/cygwin-apps/setup/choose.h,v retrieving revision 2.40 diff -u -p -r2.40 choose.h --- choose.h 15 Feb 2010 00:45:01 -0000 2.40 +++ choose.h 30 Aug 2012 09:01:53 -0000 @@ -29,8 +29,8 @@ public: ~ChooserPage (); virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); - virtual BOOL CALLBACK OnMouseWheel (UINT message, WPARAM wParam, - LPARAM lParam); + virtual INT_PTR CALLBACK OnMouseWheel (UINT message, WPARAM wParam, + LPARAM lParam); bool Create (); virtual void OnInit (); Index: filemanip.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/filemanip.cc,v retrieving revision 2.35 diff -u -p -r2.35 filemanip.cc --- filemanip.cc 1 Mar 2010 15:18:39 -0000 2.35 +++ filemanip.cc 30 Aug 2012 09:01:53 -0000 @@ -514,7 +514,7 @@ nt_wfopen (const wchar_t *wpath, const c return NULL; } wname[1] = L'\\'; - int fd = _open_osfhandle ((long) h, oflags); + int fd = _open_osfhandle ((intptr_t) h, oflags); if (fd < 0) return NULL; return _fdopen (fd, mode); Index: filemanip.h =================================================================== RCS file: /cvs/cygwin-apps/setup/filemanip.h,v retrieving revision 1.15 diff -u -p -r1.15 filemanip.h --- filemanip.h 11 May 2009 10:49:15 -0000 1.15 +++ filemanip.h 30 Aug 2012 09:01:53 -0000 @@ -16,6 +16,7 @@ #ifndef SETUP_FILEMANIP_H #define SETUP_FILEMANIP_H +#include <sys/types.h> #include <string> extern int find_tar_ext (const char *path); Index: gpg-packet.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/gpg-packet.cc,v retrieving revision 2.1 diff -u -p -r2.1 gpg-packet.cc --- gpg-packet.cc 22 Jun 2008 02:37:16 -0000 2.1 +++ gpg-packet.cc 30 Aug 2012 09:01:53 -0000 @@ -26,6 +26,7 @@ static const char *cvsid = #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include "win32.h" #include "io_stream.h" #include "gcrypt.h" #include "gpg-packet.h" @@ -42,7 +43,9 @@ static const char *cvsid = #define MESSAGE while (0) msg #endif /* CRYPTODEBUGGING */ +#ifndef ARRAYSIZE #define ARRAYSIZE(_ar) (sizeof (_ar) / sizeof (_ar[0])) +#endif static const struct { char from; char to; } RFC4880HashCodesToGPGHashCodes[] = { Index: main.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/main.cc,v retrieving revision 2.67 diff -u -p -r2.67 main.cc --- main.cc 3 Jun 2012 15:00:06 -0000 2.67 +++ main.cc 30 Aug 2012 09:01:53 -0000 @@ -33,7 +33,6 @@ static const char *cvsid = #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 -#define CINTERFACE #include "win32.h" #include <commctrl.h> #include "shlobj.h" @@ -80,6 +79,10 @@ static const char *cvsid = #include <wincon.h> #include <fstream> +#ifdef __MINGW64_VERSION_MAJOR +extern char **_argv; +#endif + using namespace std; HINSTANCE hinstance; @@ -161,8 +164,8 @@ main_display () // done later, in the thread which actually creates the shortcuts. extern IShellLink *sl; CoInitializeEx (NULL, COINIT_APARTMENTTHREADED); - HRESULT res = CoCreateInstance (&CLSID_ShellLink, NULL, - CLSCTX_INPROC_SERVER, &IID_IShellLink, + HRESULT res = CoCreateInstance (CLSID_ShellLink, NULL, + CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *) & sl); if (res) { @@ -209,7 +212,7 @@ main_display () // Uninitalize COM if (sl) - sl->lpVtbl->Release (sl); + sl->Release (); CoUninitialize (); } @@ -240,6 +243,12 @@ WinMain (HINSTANCE h, snprintf(locale, sizeof locale, ".%u", GetACP()); setlocale(LC_ALL, locale); + char **_argv; + int argc; + for (argc = 0, _argv = __argv; *_argv; _argv++) + ++argc; + _argv = __argv; + set_legacy (_argv[0]); if (is_legacy && IsWindowsNT ()) @@ -271,13 +280,6 @@ WinMain (HINSTANCE h, GetCurrentDirectory (MAX_PATH, cwd); local_dir = std::string (cwd); - // TODO: make an equivalent for __argv under cygwin. - char **_argv; - int argc; - for (argc = 0, _argv = __argv; *_argv; _argv++) - ++argc; - _argv = __argv; - if (!GetOption::GetInstance ().Process (argc,_argv, NULL)) exit (1); Index: mklink2.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/mklink2.cc,v retrieving revision 2.12 diff -u -p -r2.12 mklink2.cc --- mklink2.cc 10 Aug 2010 20:38:00 -0000 2.12 +++ mklink2.cc 30 Aug 2012 09:01:53 -0000 @@ -1,4 +1,3 @@ -#define CINTERFACE #include <stdlib.h> #include <wchar.h> #include "win32.h" @@ -29,16 +28,16 @@ make_link_2 (char const *exepath, char c WCHAR widepath[MAX_PATH]; if (sl) { - sl->lpVtbl->QueryInterface (sl, &IID_IPersistFile, (void **) &pf); + sl->QueryInterface (IID_IPersistFile, (void **) &pf); - sl->lpVtbl->SetPath (sl, exepath); - sl->lpVtbl->SetArguments (sl, args); - sl->lpVtbl->SetIconLocation (sl, icon, 0); + sl->SetPath (exepath); + sl->SetArguments (args); + sl->SetIconLocation (icon, 0); MultiByteToWideChar (CP_ACP, 0, lname, -1, widepath, MAX_PATH); - pf->lpVtbl->Save (pf, widepath, TRUE); + pf->Save (widepath, TRUE); - pf->lpVtbl->Release (pf); + pf->Release (); } } Index: netio.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/netio.cc,v retrieving revision 2.15 diff -u -p -r2.15 netio.cc --- netio.cc 22 Jun 2008 02:37:16 -0000 2.15 +++ netio.cc 30 Aug 2012 09:01:53 -0000 @@ -233,7 +233,7 @@ auth_cmd (HWND h, int id, HWND hwndctl, return 0; } -static BOOL CALLBACK +static INT_PTR CALLBACK auth_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) Index: ntdll.h =================================================================== RCS file: /cvs/cygwin-apps/setup/ntdll.h,v retrieving revision 2.3 diff -u -p -r2.3 ntdll.h --- ntdll.h 10 Aug 2010 20:38:00 -0000 2.3 +++ ntdll.h 30 Aug 2012 09:01:53 -0000 @@ -16,8 +16,15 @@ #define NTOSAPI +#ifdef __MINGW64_VERSION_MAJOR +#include <winternl.h> +#include <ntdef.h> +#include <ntstatus.h> +#define DDKAPI __stdcall +#else #include "ddk/ntapi.h" #include "ddk/ntifs.h" +#endif extern "C" { NTSTATUS DDKAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, Index: package_message.h =================================================================== RCS file: /cvs/cygwin-apps/setup/package_message.h,v retrieving revision 1.3 diff -u -p -r1.3 package_message.h --- package_message.h 10 Aug 2010 20:38:01 -0000 1.3 +++ package_message.h 30 Aug 2012 09:01:53 -0000 @@ -16,7 +16,7 @@ #include "UserSettings.h" #include "state.h" #include <stdlib.h> -#include <windows.h> +#include "win32.h" class packagemessage { Index: proppage.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/proppage.cc,v retrieving revision 2.21 diff -u -p -r2.21 proppage.cc --- proppage.cc 19 Feb 2012 13:57:03 -0000 2.21 +++ proppage.cc 30 Aug 2012 09:01:53 -0000 @@ -81,7 +81,7 @@ PropertyPage::Create (DLGPROC dlgproc, return true; } -BOOL CALLBACK +INT_PTR CALLBACK PropertyPage::FirstDialogProcReflector (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -96,25 +96,25 @@ PropertyPage::FirstDialogProcReflector ( This = (PropertyPage *) (((PROPSHEETPAGE *) lParam)->lParam); - SetWindowLong (hwnd, DWL_USER, (DWORD) This); - SetWindowLong (hwnd, DWL_DLGPROC, (DWORD) DialogProcReflector); + SetWindowLongPtr (hwnd, DWLP_USER, (LONG_PTR) This); + SetWindowLongPtr (hwnd, DWLP_DLGPROC, (LONG_PTR) DialogProcReflector); This->SetHWND (hwnd); return This->DialogProc (message, wParam, lParam); } -BOOL CALLBACK +INT_PTR CALLBACK PropertyPage::DialogProcReflector (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PropertyPage *This; - This = (PropertyPage *) GetWindowLong (hwnd, DWL_USER); + This = (PropertyPage *) GetWindowLongPtr (hwnd, DWLP_USER); return This->DialogProc (message, wParam, lParam); } -BOOL CALLBACK +INT_PTR CALLBACK PropertyPage::DialogProc (UINT message, WPARAM wParam, LPARAM lParam) { try @@ -143,7 +143,7 @@ PropertyPage::DialogProc (UINT message, { case PSN_APPLY: { - SetWindowLong (GetHWND (), DWL_MSGRESULT, PSNRET_NOERROR); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; } case PSN_SETACTIVE: @@ -178,7 +178,7 @@ PropertyPage::DialogProc (UINT message, if(!wantsActivation()) { - ::SetWindowLong (GetHWND (), DWL_MSGRESULT, -1); + ::SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, -1); return TRUE; } @@ -194,29 +194,29 @@ PropertyPage::DialogProc (UINT message, if (nextwindow == -2) { unattended_mode = attended; - SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, 0); return TRUE; } else if (nextwindow == -1) { - SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, 0); return TRUE; } else if (nextwindow == 0) { - SetWindowLong (GetHWND (), DWL_MSGRESULT, -1); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, -1); return TRUE; } else { - SetWindowLong (GetHWND (), DWL_MSGRESULT, nextwindow); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, nextwindow); return TRUE; } } else { // 0 == Accept activation, -1 = Don't accept - ::SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + ::SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, 0); return TRUE; } @@ -226,28 +226,28 @@ PropertyPage::DialogProc (UINT message, { OnDeactivate (); // FALSE = Allow deactivation - SetWindowLong (GetHWND (), DWL_MSGRESULT, FALSE); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, FALSE); return TRUE; } case PSN_WIZNEXT: { LONG retval; retval = OnNext (); - SetWindowLong (GetHWND (), DWL_MSGRESULT, retval); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, retval); return TRUE; } case PSN_WIZBACK: { LONG retval; retval = OnBack (); - SetWindowLong (GetHWND (), DWL_MSGRESULT, retval); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, retval); return TRUE; } case PSN_WIZFINISH: { OnFinish (); // False = Allow the wizard to finish - SetWindowLong (GetHWND (), DWL_MSGRESULT, FALSE); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, FALSE); return TRUE; } case TTN_GETDISPINFO: @@ -270,7 +270,7 @@ PropertyPage::DialogProc (UINT message, if (retval == true) { // Handled, return 0 - SetWindowLong (GetHWND (), DWL_MSGRESULT, 0); + SetWindowLongPtr (GetHWND (), DWLP_MSGRESULT, 0); return TRUE; } else if (cmdproc != NULL) @@ -334,9 +334,7 @@ PropertyPage::DialogProc (UINT message, theURL->second.brush = CreateSolidBrush (GetSysColor (COLOR_BTNFACE)); - // now this is really crazy, but apparently MSDN says we are to - // cast this brush as a BOOL and return it (?!) - return (BOOL)theURL->second.brush; + return (INT_PTR) theURL->second.brush; } case WM_MOUSEWHEEL: // we do this so that derived classes that wish to process this message @@ -362,7 +360,7 @@ PropertyPage::DialogProc (UINT message, return FALSE; } -BOOL CALLBACK +INT_PTR CALLBACK PropertyPage::OnMouseWheel (UINT message, WPARAM wParam, LPARAM lParam) { return 1; // not handled; define in a derived class to support this @@ -428,7 +426,7 @@ PropertyPage::urlWinProc (HWND hwnd, UIN case WM_LBUTTONDOWN: { // they clicked our URL! yay! - int rc = (int)ShellExecute (hwnd, "open", + intptr_t rc = (intptr_t) ShellExecute (hwnd, "open", theURL->second.url.c_str (), NULL, NULL, SW_SHOWNORMAL); if (rc <= 32) Index: proppage.h =================================================================== RCS file: /cvs/cygwin-apps/setup/proppage.h,v retrieving revision 2.14 diff -u -p -r2.14 proppage.h --- proppage.h 15 Apr 2006 21:21:25 -0000 2.14 +++ proppage.h 30 Aug 2012 09:01:53 -0000 @@ -42,10 +42,10 @@ class PropertyPage:public Window // For setting the back/finish buttons properly. bool IsFirst, IsLast; - static BOOL CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message, + static INT_PTR CALLBACK FirstDialogProcReflector (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - static BOOL CALLBACK DialogProcReflector (HWND hwnd, UINT message, + static INT_PTR CALLBACK DialogProcReflector (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); void setTitleFont (); @@ -78,10 +78,10 @@ class PropertyPage:public Window protected: SizeProcessor sizeProcessor; - virtual BOOL CALLBACK DialogProc (UINT message, WPARAM wParam, - LPARAM lParam); - virtual BOOL CALLBACK OnMouseWheel (UINT message, WPARAM wParam, - LPARAM lParam); + virtual INT_PTR CALLBACK DialogProc (UINT message, WPARAM wParam, + LPARAM lParam); + virtual INT_PTR CALLBACK OnMouseWheel (UINT message, WPARAM wParam, + LPARAM lParam); public: PropertyPage (); Index: propsheet.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/propsheet.cc,v retrieving revision 2.17 diff -u -p -r2.17 propsheet.cc --- propsheet.cc 10 Nov 2010 20:25:27 -0000 2.17 +++ propsheet.cc 30 Aug 2012 09:01:53 -0000 @@ -37,7 +37,10 @@ typedef struct _DllVersionInfo } DLLVERSIONINFO; typedef HRESULT CALLBACK (*DLLGETVERSIONPROC) (DLLVERSIONINFO * pdvi); + +#ifndef PROPSHEETHEADER_V1_SIZE #define PROPSHEETHEADER_V1_SIZE 40 +#endif // Sort of a "hidden" Windows structure. Used in the PropSheetCallback. #include <pshpack1.h> Index: site.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/site.cc,v retrieving revision 2.51 diff -u -p -r2.51 site.cc --- site.cc 23 Feb 2012 14:34:07 -0000 2.51 +++ site.cc 30 Aug 2012 09:01:53 -0000 @@ -441,7 +441,7 @@ do_download_site_info (HINSTANCE hinst, CreateThread (NULL, 0, do_download_site_info_thread, context, 0, &threadID); } -static BOOL CALLBACK +static INT_PTR CALLBACK drop_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) Index: win32.h =================================================================== RCS file: /cvs/cygwin-apps/setup/win32.h,v retrieving revision 2.27 diff -u -p -r2.27 win32.h --- win32.h 8 Mar 2012 09:20:03 -0000 2.27 +++ win32.h 30 Aug 2012 09:01:54 -0000 @@ -17,6 +17,7 @@ #ifndef SETUP_WIN32_H #define SETUP_WIN32_H +#include <sys/types.h> #include <string> /* Any include of <windows.h> should be through this file, which wraps it in @@ -42,6 +43,7 @@ * multiple declaration errors at link time. This define turns that off again. * It will default to off again in later w32api versions, but we need to work * with 3.1 for now. */ +#define DECLSPEC_IMPORT #define WINBASEAPI /* Require at least Internet Explorer 3, in order to have access to Index: window.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/window.cc,v retrieving revision 2.18 diff -u -p -r2.18 window.cc --- window.cc 29 Apr 2012 06:26:54 -0000 2.18 +++ window.cc 30 Aug 2012 09:01:54 -0000 @@ -66,13 +66,13 @@ Window::FirstWindowProcReflector (HWND h wnd = reinterpret_cast<Window *>(((LPCREATESTRUCT)lParam)->lpCreateParams); // Set a backreference to this class instance in the HWND. - SetWindowLongPtr (hwnd, GWL_USERDATA, reinterpret_cast<LONG_PTR>(wnd)); + SetWindowLongPtr (hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(wnd)); // Set a new WindowProc now that we have the peliminaries done. // We could instead simply do the contents of Window::WindowProcReflector // in the 'else' clause below, but this way we eliminate an unnecessary 'if/else' on // every message. Yeah, it's probably not worth the trouble. - SetWindowLongPtr (hwnd, GWL_WNDPROC, (LONG_PTR) & Window::WindowProcReflector); + SetWindowLongPtr (hwnd, GWLP_WNDPROC, (LONG_PTR) & Window::WindowProcReflector); // Finally, store the window handle in the class. wnd->WindowHandle = hwnd; } @@ -92,7 +92,7 @@ Window::WindowProcReflector (HWND hwnd, Window *This; // Get our this pointer - This = reinterpret_cast<Window *>(GetWindowLongPtr (hwnd, GWL_USERDATA)); + This = reinterpret_cast<Window *>(GetWindowLongPtr (hwnd, GWLP_USERDATA)); return This->WindowProc (uMsg, wParam, lParam); }