Fix ICC warning about comparing pointers of different types

error #3781: comparing a pointer to void and a pointer to a function is nonstandard

Change-Id: Ib57b52598e2f452985e9fffd1458fd651d3985d2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Thiago Macieira 2016-06-17 14:51:29 -07:00
parent fdb956a3ed
commit ffe8db538f
2 changed files with 9 additions and 9 deletions

View File

@ -149,12 +149,12 @@ QT_BEGIN_NAMESPACE
QWindowsOpengl32DLL QOpenGLStaticContext::opengl32; QWindowsOpengl32DLL QOpenGLStaticContext::opengl32;
void *QWindowsOpengl32DLL::resolve(const char *name) PROC QWindowsOpengl32DLL::resolve(const char *name)
{ {
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
void *proc = m_lib ? (void *) ::GetProcAddress(m_lib, name) : 0; PROC proc = m_lib ? ::GetProcAddress(m_lib, name) : 0;
#else #else
void *proc = m_lib ? (void *) ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0; PROC proc = m_lib ? ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0;
#endif #endif
return proc; return proc;
@ -1339,21 +1339,21 @@ QFunctionPointer QWindowsGLContext::getProcAddress(const char *procName)
// Even though we use QFunctionPointer, it does not mean the function can be called. // Even though we use QFunctionPointer, it does not mean the function can be called.
// It will need to be cast to the proper function type with the correct calling // It will need to be cast to the proper function type with the correct calling
// convention. QFunctionPointer is nothing more than a glorified void* here. // convention. QFunctionPointer is nothing more than a glorified void* here.
QFunctionPointer procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.wglGetProcAddress(procName)); PROC procAddress = QOpenGLStaticContext::opengl32.wglGetProcAddress(procName);
// We support AllGLFunctionsQueryable, which means this function must be able to // We support AllGLFunctionsQueryable, which means this function must be able to
// return a function pointer even for functions that are in GL.h and exported // return a function pointer even for functions that are in GL.h and exported
// normally from opengl32.dll. wglGetProcAddress() is not guaranteed to work for such // normally from opengl32.dll. wglGetProcAddress() is not guaranteed to work for such
// functions, however in QT_OPENGL_DYNAMIC builds QOpenGLFunctions will just blindly // functions, however in QT_OPENGL_DYNAMIC builds QOpenGLFunctions will just blindly
// call into here for _any_ OpenGL function. // call into here for _any_ OpenGL function.
if (!procAddress || procAddress == reinterpret_cast<void *>(0x1) || procAddress == reinterpret_cast<void *>(0x2) if (!procAddress || procAddress == reinterpret_cast<PROC>(0x1) || procAddress == reinterpret_cast<PROC>(0x2)
|| procAddress == reinterpret_cast<void *>(0x3) || procAddress == reinterpret_cast<void *>(-1)) || procAddress == reinterpret_cast<PROC>(0x3) || procAddress == reinterpret_cast<PROC>(-1))
procAddress = reinterpret_cast<QFunctionPointer>(QOpenGLStaticContext::opengl32.resolve(procName)); procAddress = QOpenGLStaticContext::opengl32.resolve(procName);
if (QWindowsContext::verbose > 1) if (QWindowsContext::verbose > 1)
qCDebug(lcQpaGl) << __FUNCTION__ << procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress; qCDebug(lcQpaGl) << __FUNCTION__ << procName << QOpenGLStaticContext::opengl32.wglGetCurrentContext() << "returns" << procAddress;
return procAddress; return reinterpret_cast<QFunctionPointer>(procAddress);
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -122,7 +122,7 @@ struct QWindowsOpengl32DLL
void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params); void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params);
const GLubyte * (APIENTRY * glGetString)(GLenum name); const GLubyte * (APIENTRY * glGetString)(GLenum name);
void *resolve(const char *name); PROC resolve(const char *name);
private: private:
HMODULE m_lib; HMODULE m_lib;
bool m_nonOpengl32; bool m_nonOpengl32;