From 9c67be287ee640e1942d21c3a31a23fa73e210b9 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Fri, 6 Feb 2015 12:04:22 +0000 Subject: [PATCH] Fix warning on mingw about casting a function pointer through a void *. Fix warning on MSVC about GetModuleHandle potentially failing. --- src/win32/thread.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 8b4a6618..aae37ccf 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -657,12 +657,16 @@ namespace boost { return SetWaitableTimer(hTimer, lpDueTime, lPeriod, pfnCompletionRoutine, lpArgToCompletionRoutine, FALSE); } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 6387) // MSVC sanitiser warns that GetModuleHandleA() might fail +#endif static inline setwaitabletimerex_t SetWaitableTimerEx() { static setwaitabletimerex_t setwaitabletimerex_impl; if(setwaitabletimerex_impl) return setwaitabletimerex_impl; - void *addr=(void *) GetProcAddress( + void (*addr)()=(void (*)()) GetProcAddress( #if !defined(BOOST_NO_ANSI_APIS) GetModuleHandleA("KERNEL32.DLL"), #else @@ -675,6 +679,9 @@ namespace boost setwaitabletimerex_impl=&SetWaitableTimerEx_emulation; return setwaitabletimerex_impl; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif } #endif #endif