Skip to content

Commit 9db790c

Browse files
committed
Better way of dealing with libmxl bogus deprecations
1 parent 13def10 commit 9db790c

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

src/pch.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@
66

77
#include <sys_config.h>
88

9+
#ifdef __GNUC__
10+
#define WSDDN_SUPPRESS_WARNINGS_BEGIN _Pragma("GCC diagnostic push")
11+
#define WSDDN_SUPPRESS_WARNING_HELPER0(arg) #arg
12+
#define WSDDN_SUPPRESS_WARNING_HELPER1(name) WSDDN_SUPPRESS_WARNING_HELPER0(GCC diagnostic ignored name)
13+
#define WSDDN_SUPPRESS_WARNING_HELPER2(name) WSDDN_SUPPRESS_WARNING_HELPER1(#name)
14+
#define WSDDN_SUPPRESS_WARNING(name) _Pragma(WSDDN_SUPPRESS_WARNING_HELPER2(name))
15+
#define WSDDN_SUPPRESS_WARNINGS_END _Pragma("GCC diagnostic pop")
16+
17+
#define WSDDN_IGNORE_DEPRECATED_BEGIN WSDDN_SUPPRESS_WARNINGS_BEGIN \
18+
WSDDN_SUPPRESS_WARNING(-Wdeprecated-declarations)
19+
#define WSDDN_IGNORE_DEPRECATED_END WSDDN_SUPPRESS_WARNINGS_END
20+
#else
21+
#define WSDDN_SUPPRESS_WARNINGS_BEGIN
22+
#define WSDDN_SUPPRESS_WARNING(x)
23+
#define WSDDN_SUPPRESS_WARNINGS_END
24+
25+
#define WSDDN_IGNORE_DEPRECATED_BEGIN
26+
#define WSDDN_IGNORE_DEPRECATED_END
27+
#endif
28+
929
#include <argum/parser.h>
1030
#include <argum/type-parsers.h>
1131
#include <argum/validators.h>
@@ -14,12 +34,12 @@
1434

1535
//must come before sys_string due to S macro collision
1636
#ifdef __clang__
17-
#pragma clang diagnostic push
18-
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
37+
WSDDN_SUPPRESS_WARNINGS_BEGIN
38+
WSDDN_SUPPRESS_WARNING(-Wshorten-64-to-32)
1939
#endif
2040
#include <asio.hpp>
2141
#ifdef __clang__
22-
#pragma clang diagnostic pop
42+
WSDDN_SUPPRESS_WARNINGS_END
2343
#endif
2444

2545
#include <sys_string/sys_string.h>

src/xml_wrapper.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ class XmlCharBuffer {
6363
struct XmlParserInit {
6464
XmlParserInit() {
6565
xmlInitParser();
66+
67+
//libxml marked xmlThrDefXxx variants deprecated without providing any sane
68+
//alternative to suppress its idiotic default logging to stderr
69+
//We will keep using these for now.
70+
WSDDN_IGNORE_DEPRECATED_BEGIN
6671
xmlSetGenericErrorFunc(nullptr, XmlParserInit::errorFunc);
67-
#if LIBXML_VERSION < 21300
6872
xmlThrDefSetGenericErrorFunc(nullptr, XmlParserInit::errorFunc);
69-
#endif
70-
73+
7174
xmlSetStructuredErrorFunc(nullptr, XmlParserInit::structuredErrorFunc);
72-
#if LIBXML_VERSION < 21300
7375
xmlThrDefSetStructuredErrorFunc(nullptr, XmlParserInit::structuredErrorFunc);
74-
#endif
76+
WSDDN_IGNORE_DEPRECATED_END
77+
7578
}
7679
~XmlParserInit() {
7780
xmlCleanupParser();

0 commit comments

Comments
 (0)