From fc26b053df9cbf3886c4c6efc5a678fa1f60b20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 31 Oct 2013 13:03:24 +0100 Subject: Declare Cocoa conversion funcs in objc-mode only. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In practice, there are several ways to forward-declare objective-c classes. Qt uses "struct objc_object", other projects may use a plain "class". Mismatched forward declarations will lead to compile errors, and this is a form of header pollution. dd5e40d9 added a workaround where Q_FORWARD_DECLARE_OBJC_CLASS can be predefined in order to sync up the declarations. Make forward declaration clashes less likely by forward-declaring in objc-mode only. Change-Id: I9f7a399d64dc88bfe05d5385b3d46b5302112aef Reviewed-by: Tor Arne Vestbø --- src/corelib/io/qurl.h | 6 +++++- src/corelib/tools/qstring.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index e7edb4365e..637eac87b6 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -51,8 +51,10 @@ #include #ifdef Q_OS_MAC -Q_FORWARD_DECLARE_OBJC_CLASS(NSURL); Q_FORWARD_DECLARE_CF_TYPE(CFURL); +# ifdef __OBJC__ +Q_FORWARD_DECLARE_OBJC_CLASS(NSURL); +# endif #endif QT_BEGIN_NAMESPACE @@ -265,8 +267,10 @@ public: #if defined(Q_OS_MAC) || defined(Q_QDOC) static QUrl fromCFURL(CFURLRef url); CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED; +# if defined(__OBJC__) || defined(Q_QDOC) static QUrl fromNSURL(const NSURL *url); NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED; +# endif #endif #if QT_DEPRECATED_SINCE(5,0) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 2eaed65148..3140af084b 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -65,8 +65,10 @@ namespace std #endif #ifdef Q_OS_MAC -Q_FORWARD_DECLARE_OBJC_CLASS(NSString); Q_FORWARD_DECLARE_CF_TYPE(CFString); +# ifdef __OBJC__ +Q_FORWARD_DECLARE_OBJC_CLASS(NSString); +# endif #endif QT_BEGIN_NAMESPACE @@ -681,8 +683,10 @@ public: #if defined(Q_OS_MAC) || defined(Q_QDOC) static QString fromCFString(CFStringRef string); CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED; +# if defined(__OBJC__) || defined(Q_QDOC) static QString fromNSString(const NSString *string); NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED; +# endif #endif // compatibility struct Null { }; -- cgit v1.2.3