diff --git a/include/libxml/xmlexports.h b/include/libxml/xmlexports.h index acf4320b..c4b74810 100644 --- a/include/libxml/xmlexports.h +++ b/include/libxml/xmlexports.h @@ -77,43 +77,6 @@ #endif #endif -/* - * Warnings pragmas, should be moved from public headers - */ - -#if defined(__LCC__) - - #define XML_IGNORE_FPTR_CAST_WARNINGS - #define XML_POP_WARNINGS \ - _Pragma("diag_default 1215") - -#elif defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) - - #if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 800) - #define XML_IGNORE_FPTR_CAST_WARNINGS \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \ - _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"") - #else - #define XML_IGNORE_FPTR_CAST_WARNINGS \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wpedantic\"") - #endif - #define XML_POP_WARNINGS \ - _Pragma("GCC diagnostic pop") - -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - - #define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push)) - #define XML_POP_WARNINGS __pragma(warning(pop)) - -#else - - #define XML_IGNORE_FPTR_CAST_WARNINGS - #define XML_POP_WARNINGS - -#endif - /* * Originally declared in xmlversion.h which is generated */ diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h index 0aaddc09..eb513fc3 100644 --- a/python/libxml_wrap.h +++ b/python/libxml_wrap.h @@ -65,19 +65,22 @@ * Macros to ignore deprecation warnings */ #if defined(__LCC__) -#define XML_IGNORE_DEPRECATION_WARNINGS \ - _Pragma("diag_suppress 1215") + #define XML_IGNORE_DEPRECATION_WARNINGS _Pragma("diag_suppress 1215") + #define XML_POP_WARNINGS _Pragma("diag_default 1215") #elif defined(__clang__) || \ - (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) -#define XML_IGNORE_DEPRECATION_WARNINGS \ + (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)) + #define XML_IGNORE_DEPRECATION_WARNINGS \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") + #define XML_POP_WARNINGS _Pragma("GCC diagnostic pop") #elif defined (_MSC_VER) && (_MSC_VER >= 1400) -#define XML_IGNORE_DEPRECATION_WARNINGS \ + #define XML_IGNORE_DEPRECATION_WARNINGS \ __pragma(warning(push)) \ __pragma(warning(disable : 4996)) + #define XML_POP_WARNINGS __pragma(warning(pop)) #else -#define XML_IGNORE_DEPRECATION_WARNINGS + #define XML_IGNORE_DEPRECATION_WARNINGS + #define XML_POP_WARNINGS #endif #define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \ diff --git a/python/types.c b/python/types.c index 90ca7d88..7648281b 100644 --- a/python/types.c +++ b/python/types.c @@ -112,9 +112,8 @@ libxml_PyFileGet(PyObject *f) { if (hntdll == NULL) return(NULL); -XML_IGNORE_FPTR_CAST_WARNINGS - NtQueryInformationFile = (t_NtQueryInformationFile)GetProcAddress(hntdll, "NtQueryInformationFile"); -XML_POP_WARNINGS + NtQueryInformationFile = (t_NtQueryInformationFile) (void (*)(void)) + GetProcAddress(hntdll, "NtQueryInformationFile"); if (NtQueryInformationFile != NULL && (NtQueryInformationFile((HANDLE)w_fh, diff --git a/xmlmodule.c b/xmlmodule.c index 3f105fd4..407227c1 100644 --- a/xmlmodule.c +++ b/xmlmodule.c @@ -289,10 +289,10 @@ xmlModulePlatformClose(void *handle) static int xmlModulePlatformSymbol(void *handle, const char *name, void **symbol) { -XML_IGNORE_FPTR_CAST_WARNINGS - *symbol = GetProcAddress(handle, name); + FARPROC proc = GetProcAddress(handle, name); + + memcpy(symbol, &proc, sizeof(proc)); return (NULL == *symbol) ? -1 : 0; -XML_POP_WARNINGS } #endif /* _WIN32 */ diff --git a/xpath.c b/xpath.c index 0289b467..11adfb0c 100644 --- a/xpath.c +++ b/xpath.c @@ -3819,6 +3819,7 @@ int xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri, xmlXPathFunction f) { int ret; + void *payload; if (ctxt == NULL) return(-1); @@ -3833,9 +3834,8 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name, } if (f == NULL) return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL)); -XML_IGNORE_FPTR_CAST_WARNINGS - ret = xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f); -XML_POP_WARNINGS + memcpy(&payload, &f, sizeof(f)); + ret = xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, payload); if (ret < 0) { xmlXPathErrMemory(ctxt); return(-1); @@ -3892,6 +3892,7 @@ xmlXPathFunction xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri) { xmlXPathFunction ret; + void *payload; if (ctxt == NULL) return(NULL); @@ -3926,9 +3927,9 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name, if (ctxt->funcHash == NULL) return(NULL); -XML_IGNORE_FPTR_CAST_WARNINGS - ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri); -XML_POP_WARNINGS + payload = xmlHashLookup2(ctxt->funcHash, name, ns_uri); + memcpy(&ret, &payload, sizeof(payload)); + return(ret); }