Merge branch 'gcc8-msw-warns'

Fix tons of warnings given by default by gcc 8, potentially fixing some
real problems in Win64 build in the process.

See https://github.com/wxWidgets/wxWidgets/pull/822
This commit is contained in:
Vadim Zeitlin
2018-06-10 23:41:05 +02:00
18 changed files with 141 additions and 112 deletions

View File

@@ -79,11 +79,6 @@ bool wxVListBox::Create(wxWindow *parent,
long style,
const wxString& name)
{
#ifdef __WXMSW__
if ( (style & wxBORDER_MASK) == wxDEFAULT )
style |= wxBORDER_THEME;
#endif
style |= wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE;
if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) )
return false;

View File

@@ -66,14 +66,14 @@ static void DDEDeleteConnection(HCONV hConv);
static wxDDEServer *DDEFindServer(const wxString& s);
extern "C" HDDEDATA EXPENTRY
_DDECallback(WORD wType,
WORD wFmt,
_DDECallback(UINT wType,
UINT wFmt,
HCONV hConv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hData,
DWORD lData1,
DWORD lData2);
ULONG_PTR lData1,
ULONG_PTR lData2);
// Add topic name to atom table before using in conversations
static HSZ DDEAddAtom(const wxString& string);
@@ -149,9 +149,7 @@ extern void wxDDEInitialize()
if ( !DDEInitialized )
{
// Should insert filter flags
PFNCALLBACK callback = (PFNCALLBACK)
MakeProcInstance((FARPROC)_DDECallback, wxGetInstance());
UINT rc = DdeInitialize(&DDEIdInst, callback, APPCLASS_STANDARD, 0L);
UINT rc = DdeInitialize(&DDEIdInst, _DDECallback, APPCLASS_STANDARD, 0L);
if ( rc != DMLERR_NO_ERROR )
{
DDELogError(wxT("Failed to initialize DDE"), rc);
@@ -773,14 +771,14 @@ bool wxDDEConnection::DoAdvise(const wxString& item,
#define DDERETURN HDDEDATA
HDDEDATA EXPENTRY
_DDECallback(WORD wType,
WORD wFmt,
_DDECallback(UINT wType,
UINT wFmt,
HCONV hConv,
HSZ hsz1,
HSZ hsz2,
HDDEDATA hData,
DWORD WXUNUSED(lData1),
DWORD WXUNUSED(lData2))
ULONG_PTR WXUNUSED(lData1),
ULONG_PTR WXUNUSED(lData2))
{
switch (wType)
{

View File

@@ -147,8 +147,24 @@ wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#endif
typedef HGLRC(WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)
(HDC hDC, HGLRC hShareContext, const int *attribList);
// This helper function only exists to suppress unavoidable gcc 8 warnings
// about incompatible function casts.
template <typename T>
inline T wxWGLProcCast(PROC proc)
{
wxGCC_WARNING_SUPPRESS_CAST_FUNCTION_TYPE()
return reinterpret_cast<T>(proc);
wxGCC_WARNING_RESTORE_CAST_FUNCTION_TYPE()
}
// this macro defines a variable of type "name_t" called "name" and initializes
// it with the pointer to WGL function "name" (which may be NULL)
//
// NB: type name_t must be defined by the code using the macro
#define wxDEFINE_WGL_FUNC(name) \
name##_t name = wxWGLProcCast<name##_t>(wglGetProcAddress(#name))
// ----------------------------------------------------------------------------
// libraries
@@ -580,9 +596,11 @@ wxGLContext::wxGLContext(wxGLCanvas *win,
wxCHECK_RET( tempContext, "wglCreateContext failed!" );
wglMakeCurrent(win->GetHDC(), tempContext);
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB
= (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB");
typedef HGLRC(WINAPI * wglCreateContextAttribsARB_t)
(HDC hDC, HGLRC hShareContext, const int *attribList);
wxDEFINE_WGL_FUNC(wglCreateContextAttribsARB);
wglMakeCurrent(win->GetHDC(), NULL);
wglDeleteContext(tempContext);
@@ -810,11 +828,6 @@ bool wxGLCanvas::SwapBuffers()
}
// this macro defines a variable of type "name_t" called "name" and initializes
// it with the pointer to WGL function "name" (which may be NULL)
#define wxDEFINE_WGL_FUNC(name) \
name##_t name = (name##_t)wglGetProcAddress(#name)
/* static */
bool wxGLCanvasBase::IsExtensionSupported(const char *extension)
{

View File

@@ -160,6 +160,11 @@ enum
mcWithFrame = 16
};
typedef void (*PPRMProcType)(Movie theMovie, OSErr theErr, void* theRefCon);
typedef Boolean (*MCFilterProcType)(MovieController theController,
short action, void *params,
LONG_PTR refCon);
//---------------------------------------------------------------------------
// QT Library
//---------------------------------------------------------------------------
@@ -246,7 +251,7 @@ public:
wxDL_VOIDMETHOD_DEFINE(DisposeMovieController, (ComponentInstance ci), (ci))
wxDL_METHOD_DEFINE(int, MCSetVisible, (ComponentInstance m, int b), (m, b), 0)
wxDL_VOIDMETHOD_DEFINE(PrePrerollMovie, (Movie m, long t, Fixed r, WXFARPROC p1, void* p2), (m,t,r,p1,p2) )
wxDL_VOIDMETHOD_DEFINE(PrePrerollMovie, (Movie m, long t, Fixed r, PPRMProcType p1, void* p2), (m,t,r,p1,p2) )
wxDL_VOIDMETHOD_DEFINE(PrerollMovie, (Movie m, long t, Fixed r), (m,t,r) )
wxDL_METHOD_DEFINE(Fixed, GetMoviePreferredRate, (Movie m), (m), 0)
wxDL_METHOD_DEFINE(long, GetMovieLoadState, (Movie m), (m), 0)
@@ -263,7 +268,7 @@ public:
wxDL_VOIDMETHOD_DEFINE(MCPositionController,
(ComponentInstance ci, Rect* r, void* junk, void* morejunk), (ci,r,junk,morejunk))
wxDL_VOIDMETHOD_DEFINE(MCSetActionFilterWithRefCon,
(ComponentInstance ci, WXFARPROC cb, void* ref), (ci,cb,ref))
(ComponentInstance ci, MCFilterProcType cb, void* ref), (ci,cb,ref))
wxDL_VOIDMETHOD_DEFINE(MCGetControllerInfo, (MovieController mc, long* flags), (mc,flags))
wxDL_VOIDMETHOD_DEFINE(BeginUpdate, (CGrafPtr port), (port))
wxDL_VOIDMETHOD_DEFINE(UpdateMovie, (Movie m), (m))
@@ -804,8 +809,8 @@ bool wxQTMediaBackend::Load(const wxURI& location)
// which we don't by default.
//
m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
(WXFARPROC)wxQTMediaBackend::PPRMProc,
(void*)this);
wxQTMediaBackend::PPRMProc,
this);
return true;
}
@@ -1119,7 +1124,7 @@ bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
mcWithFrame);
m_lib.MCDoAction(m_pMC, 32, (void*)true); // mcActionSetKeysEnabled
m_lib.MCSetActionFilterWithRefCon(m_pMC,
(WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
wxQTMediaBackend::MCFilterProc, this);
m_bestSize.y += 16; // movie controller height
// By default the movie controller uses its own colour palette

View File

@@ -36,7 +36,7 @@
// global functions
// ---------------------------------------------------------------------------
extern LONG APIENTRY
extern INT_PTR APIENTRY
wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
// ===========================================================================

View File

@@ -81,10 +81,10 @@
#if USE_NOTEBOOK_ANTIFLICKER
// the pointer to standard spin button wnd proc
static WXFARPROC gs_wndprocNotebookSpinBtn = (WXFARPROC)NULL;
static WXWNDPROC gs_wndprocNotebookSpinBtn = NULL;
// the pointer to standard tab control wnd proc
static WXFARPROC gs_wndprocNotebook = (WXFARPROC)NULL;
static WXWNDPROC gs_wndprocNotebook = NULL;
LRESULT APIENTRY
wxNotebookWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
@@ -202,8 +202,7 @@ bool wxNotebook::Create(wxWindow *parent,
if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) )
{
gs_wndprocNotebook =
reinterpret_cast<WXFARPROC>(wc.lpfnWndProc);
gs_wndprocNotebook = wc.lpfnWndProc;
wc.lpszClassName = wxT("_wx_SysTabCtl32");
wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
wc.hInstance = wxGetInstance();
@@ -996,7 +995,7 @@ void wxNotebook::OnSize(wxSizeEvent& event)
{
// subclass the spin button to override WM_ERASEBKGND
if ( !gs_wndprocNotebookSpinBtn )
gs_wndprocNotebookSpinBtn = (WXFARPROC)wxGetWindowProc(child);
gs_wndprocNotebookSpinBtn = wxGetWindowProc(child);
wxSetWindowProc(child, wxNotebookSpinBtnWndProc);
m_hasSubclassedUpdown = true;

View File

@@ -113,7 +113,7 @@ namespace
{
// the pointer to standard radio button wnd proc
WXFARPROC s_wndprocRadioBtn = (WXFARPROC)NULL;
WXWNDPROC s_wndprocRadioBtn = NULL;
// Hash allowing to find wxRadioBox containing the given radio button by its
// HWND. This is used by (subclassed) radio button window proc to find the
@@ -298,7 +298,7 @@ void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
HWND hwndBtn = (HWND)hWndBtn;
if ( !s_wndprocRadioBtn )
s_wndprocRadioBtn = (WXFARPROC)wxGetWindowProc(hwndBtn);
s_wndprocRadioBtn = wxGetWindowProc(hwndBtn);
wxSetWindowProc(hwndBtn, wxRadioBtnWndProc);

View File

@@ -329,8 +329,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
// subclass the text ctrl to be able to intercept some events
gs_spinForTextCtrl[GetBuddyHwnd()] = this;
m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(),
wxBuddyTextWndProc);
m_wndProcBuddy = wxSetWindowProc(GetBuddyHwnd(), wxBuddyTextWndProc);
// associate the text window with the spin button
(void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0);

View File

@@ -92,7 +92,7 @@ struct NotifyIconData : public NOTIFYICONDATA
{
NotifyIconData(WXHWND hwnd)
{
memset(this, 0, sizeof(NOTIFYICONDATA));
wxZeroMemory(*this);
// Since Vista there is a new member hBalloonIcon which will be used
// if a user specified icon is specified in ShowBalloon(). For XP

View File

@@ -51,7 +51,7 @@
// NB: wxDlgProc must be defined here and not in dialog.cpp because the latter
// is not included by wxUniv build which does need wxDlgProc
LONG APIENTRY
INT_PTR APIENTRY
wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
// ----------------------------------------------------------------------------
@@ -1242,7 +1242,7 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event)
}
// the DialogProc for all wxWidgets dialogs
LONG APIENTRY
INT_PTR APIENTRY
wxDlgProc(HWND WXUNUSED(hDlg),
UINT message,
WPARAM WXUNUSED(wParam),

View File

@@ -1248,11 +1248,11 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
wxAssociateWinWithHandle(hwnd, this);
m_oldWndProc = (WXFARPROC)wxGetWindowProc((HWND)hWnd);
m_oldWndProc = wxGetWindowProc((HWND)hWnd);
// we don't need to subclass the window of our own class (in the Windows
// sense of the word)
if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) )
if ( !wxCheckWindowWndProc(hWnd) )
{
wxSetWindowProc(hwnd, wxWndProc);
@@ -1289,9 +1289,9 @@ void wxWindowMSW::UnsubclassWin()
if ( m_oldWndProc )
{
if ( !wxCheckWindowWndProc((WXHWND)hwnd, m_oldWndProc) )
if ( !wxCheckWindowWndProc((WXHWND)hwnd) )
{
wxSetWindowProc(hwnd, (WNDPROC)m_oldWndProc);
wxSetWindowProc(hwnd, m_oldWndProc);
}
m_oldWndProc = NULL;
@@ -1322,8 +1322,7 @@ void wxWindowMSW::DissociateHandle()
}
bool wxCheckWindowWndProc(WXHWND hWnd,
WXFARPROC WXUNUSED(wndProc))
bool wxCheckWindowWndProc(WXHWND hWnd, WXWNDPROC WXUNUSED(wndProc))
{
const wxString str(wxGetWindowClass(hWnd));
@@ -2408,7 +2407,7 @@ WXLRESULT wxWindowMSW::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM l
{
WXLRESULT rc;
if ( m_oldWndProc )
rc = ::CallWindowProc(CASTWNDPROC m_oldWndProc, GetHwnd(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam);
rc = ::CallWindowProc(m_oldWndProc, GetHwnd(), nMsg, wParam, lParam);
else
rc = ::DefWindowProc(GetHwnd(), nMsg, wParam, lParam);
@@ -6867,8 +6866,8 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd)
// in active frames and dialogs, regardless of where the focus is.
static HHOOK wxTheKeyboardHook = 0;
int APIENTRY
wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
LRESULT APIENTRY
wxKeyboardHook(int nCode, WXWPARAM wParam, WXLPARAM lParam)
{
DWORD hiWord = HIWORD(lParam);
if ( nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0) )
@@ -6935,7 +6934,7 @@ void wxSetKeyboardHook(bool doIt)
wxTheKeyboardHook = ::SetWindowsHookEx
(
WH_KEYBOARD,
(HOOKPROC)wxKeyboardHook,
wxKeyboardHook,
NULL, // must be NULL for process hook
::GetCurrentThreadId()
);