From 4b10298de54a7cacb5f25601f8e3ae5d233806d3 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Wed, 4 Jul 2018 11:36:14 -0400 Subject: CBOR: Avoid conflicts with X11 #defines in our enums Since the .cpp files in the implementation don't actually include the offending X11 headers they don't need the fix. This just adjusts the headers themselves to unbreak the namespace for just long enough to declare the right enums. Change-Id: If33757aa2289f8fe7b81836f9c08b0ad4592bc32 Reviewed-by: Thiago Macieira --- src/corelib/serialization/qcborcommon.h | 14 ++++++++++++++ src/corelib/serialization/qcborstream.h | 11 +++++++++++ src/corelib/serialization/qcborvalue.h | 11 +++++++++++ 3 files changed, 36 insertions(+) (limited to 'src/corelib/serialization') diff --git a/src/corelib/serialization/qcborcommon.h b/src/corelib/serialization/qcborcommon.h index 2c6d44657d..9661cd70bb 100644 --- a/src/corelib/serialization/qcborcommon.h +++ b/src/corelib/serialization/qcborcommon.h @@ -48,6 +48,13 @@ #pragma qt_class(QtCborCommon) #endif +/* X11 headers use these values too, but as defines */ +#if defined(False) && defined(True) +# define QT_X11_DEFINES_FOUND 1 +# undef True +# undef False +#endif + QT_BEGIN_NAMESPACE enum class QCborSimpleType : quint8 { @@ -130,4 +137,11 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QCborTag) +// To avoid changing namespace we need to reinstate defines, even though our .cpp +// will then have to remove them again. +#if defined(QT_X11_DEFINES_FOUND) +# define True 1 +# define False 0 +#endif + #endif // QCBORSTREAM_H diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h index 22f6a8218e..85acfd85ea 100644 --- a/src/corelib/serialization/qcborstream.h +++ b/src/corelib/serialization/qcborstream.h @@ -47,6 +47,12 @@ #include #include +// See qcborcommon.h for why we check +#if defined(QT_X11_DEFINES_FOUND) +# undef True +# undef False +#endif + QT_BEGIN_NAMESPACE class QIODevice; @@ -253,4 +259,9 @@ private: QT_END_NAMESPACE +#if defined(QT_X11_DEFINES_FOUND) +# define True 1 +# define False 0 +#endif + #endif // QCBORSTREAM_H diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index b7280dd35f..8411830835 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -51,6 +51,12 @@ #include #include +// See qcborcommon.h for why we check +#if defined(QT_X11_DEFINES_FOUND) +# undef True +# undef False +#endif + #if QT_HAS_INCLUDE() # include #endif @@ -438,4 +444,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v); QT_END_NAMESPACE +#if defined(QT_X11_DEFINES_FOUND) +# define True 1 +# define False 0 +#endif + #endif // QCBORVALUE_H -- cgit v1.2.3