From f2b6307af2895d312670a5ee6781ef8f1b46d799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 28 Jan 2014 16:31:49 +0100 Subject: [PATCH] Warn the user when compiling Objective-C files (.m) that includes Qt Xcode project templates will by default create source files that ends with .m (obj-c). If you try to include Qt from such files, you will get a bunch of compile errors, since the compiler will not understand C++ concepts, such as namespaces. To ease mixing native iOS and OS X apps with Qt, we print a warning to the console, so that the error messages are easier to understand and fix, by renaming the offending file to .mm. Change-Id: I192f460f9ca53145b7193dec1cfe7c095ae149a1 Reviewed-by: Thiago Macieira --- src/corelib/global/qnamespace.h | 4 ++++ src/corelib/kernel/qobjectdefs.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index e6caf798d8a..366cfb5ed9a 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -44,6 +44,10 @@ #include +#if defined(__OBJC__) && !defined(__cplusplus) +# warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)" +#endif + QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index c3141c1abb9..fe107f14253 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -42,6 +42,10 @@ #ifndef QOBJECTDEFS_H #define QOBJECTDEFS_H +#if defined(__OBJC__) && !defined(__cplusplus) +# warning "File built in Objective-C mode (.m), but using Qt requires Objective-C++ (.mm)" +#endif + #include #include