From cf70aa93d016df4a433d42ab537014ef694c8161 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Fri, 26 Apr 2013 11:03:10 +1000 Subject: Use union to allow access to dynamic library functions. --- qt/ScintillaEditBase/PlatQt.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'qt') diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index fa76f2614..ed2ed99f6 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -1089,8 +1089,17 @@ public: virtual Function FindFunction(const char *name) { if (lib) { - void *fnAddress = lib->resolve(name); - return static_cast(fnAddress); + // C++ standard doesn't like casts betwen function pointers and void pointers so use a union + union { +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + QFunctionPointer fp; +#else + void *fp; +#endif + Function f; + } fnConv; + fnConv.fp = lib->resolve(name); + return fnConv.f; } return NULL; } -- cgit v1.2.3