Skip to content

Commit

Permalink
Better way of dealing with libmxl bogus deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed Oct 3, 2024
1 parent 13def10 commit 9db790c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
26 changes: 23 additions & 3 deletions src/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@

#include <sys_config.h>

#ifdef __GNUC__
#define WSDDN_SUPPRESS_WARNINGS_BEGIN _Pragma("GCC diagnostic push")
#define WSDDN_SUPPRESS_WARNING_HELPER0(arg) #arg
#define WSDDN_SUPPRESS_WARNING_HELPER1(name) WSDDN_SUPPRESS_WARNING_HELPER0(GCC diagnostic ignored name)
#define WSDDN_SUPPRESS_WARNING_HELPER2(name) WSDDN_SUPPRESS_WARNING_HELPER1(#name)
#define WSDDN_SUPPRESS_WARNING(name) _Pragma(WSDDN_SUPPRESS_WARNING_HELPER2(name))
#define WSDDN_SUPPRESS_WARNINGS_END _Pragma("GCC diagnostic pop")

#define WSDDN_IGNORE_DEPRECATED_BEGIN WSDDN_SUPPRESS_WARNINGS_BEGIN \
WSDDN_SUPPRESS_WARNING(-Wdeprecated-declarations)
#define WSDDN_IGNORE_DEPRECATED_END WSDDN_SUPPRESS_WARNINGS_END
#else
#define WSDDN_SUPPRESS_WARNINGS_BEGIN
#define WSDDN_SUPPRESS_WARNING(x)
#define WSDDN_SUPPRESS_WARNINGS_END

#define WSDDN_IGNORE_DEPRECATED_BEGIN
#define WSDDN_IGNORE_DEPRECATED_END
#endif

#include <argum/parser.h>
#include <argum/type-parsers.h>
#include <argum/validators.h>
Expand All @@ -14,12 +34,12 @@

//must come before sys_string due to S macro collision
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
WSDDN_SUPPRESS_WARNINGS_BEGIN
WSDDN_SUPPRESS_WARNING(-Wshorten-64-to-32)
#endif
#include <asio.hpp>
#ifdef __clang__
#pragma clang diagnostic pop
WSDDN_SUPPRESS_WARNINGS_END
#endif

#include <sys_string/sys_string.h>
Expand Down
13 changes: 8 additions & 5 deletions src/xml_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ class XmlCharBuffer {
struct XmlParserInit {
XmlParserInit() {
xmlInitParser();

//libxml marked xmlThrDefXxx variants deprecated without providing any sane
//alternative to suppress its idiotic default logging to stderr
//We will keep using these for now.
WSDDN_IGNORE_DEPRECATED_BEGIN
xmlSetGenericErrorFunc(nullptr, XmlParserInit::errorFunc);
#if LIBXML_VERSION < 21300
xmlThrDefSetGenericErrorFunc(nullptr, XmlParserInit::errorFunc);
#endif


xmlSetStructuredErrorFunc(nullptr, XmlParserInit::structuredErrorFunc);
#if LIBXML_VERSION < 21300
xmlThrDefSetStructuredErrorFunc(nullptr, XmlParserInit::structuredErrorFunc);
#endif
WSDDN_IGNORE_DEPRECATED_END

}
~XmlParserInit() {
xmlCleanupParser();
Expand Down

0 comments on commit 9db790c

Please sign in to comment.