GNU bug report logs - #27041
MacOS 10.6: fix NS build

Previous Next

Package: emacs;

Reported by: "Charles A. Roelli" <charles <at> aurox.ch>

Date: Tue, 23 May 2017 18:58:02 UTC

Severity: normal

Merged with 27059

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Third <alan <at> idiocy.org>
To: npostavs <at> users.sourceforge.net
Cc: 27041 <at> debbugs.gnu.org, "Charles A. Roelli" <charles <at> aurox.ch>
Subject: bug#27041: [PATCH] Check if instancetype supported in ObjC
Date: Thu, 25 May 2017 19:46:35 +0100
* configure.ac: Add check for instancetype.
* src/nsterm.h [!NATIVE_OBJC_INSTANCETYPE]: Define instancetype.
---
 configure.ac | 17 +++++++++++++++++
 src/nsterm.h | 20 +++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6d23b5d214..b525666a85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1980,6 +1980,23 @@ AC_DEFUN
 AC_SUBST(NS_OBJ)
 AC_SUBST(NS_OBJC_OBJ)
 
+AC_CACHE_CHECK(
+  [if the Objective C compiler supports instancetype],
+  [emacs_cv_objc_instancetype],
+  [AC_LANG_PUSH([Objective C])
+   AC_COMPILE_IFELSE(
+     [AC_LANG_SOURCE([[@interface Test
+                        + (instancetype)test;
+                        @end]])],
+     emacs_cv_objc_instancetype=yes,
+     emacs_cv_objc_instancetype=no)
+   AC_LANG_POP([Objective C])])
+
+if test x$emacs_cv_objc_instancetype = xyes ; then
+  AC_DEFINE(NATIVE_OBJC_INSTANCETYPE, 1,
+            [Define if ObjC compiler supports instancetype natively.])
+fi
+
 HAVE_W32=no
 W32_OBJ=
 W32_LIBS=
diff --git a/src/nsterm.h b/src/nsterm.h
index 8f3d92b353..f75e3759e4 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -62,15 +62,6 @@ typedef CGFloat EmacsCGFloat;
 typedef float EmacsCGFloat;
 #endif
 
-/* FIXME: instancetype is a language built-in, but older versions of
-   Clang don't support it, and I don't know if GCC supports it at all.
-   Should this be tested for in ./configure? */
-#if defined (NS_IMPL_GNUSTEP)
-    || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
-typedef id instancetype;
-typedef NSUInteger NSWindowStyleMask;
-#endif
-
 /* ==========================================================================
 
    Trace support
@@ -365,6 +356,12 @@ char const * nstrace_fullscreen_type_name (int);
 #endif
 
 
+/* If the compiler doesn't support instancetype, map it to id. */
+#ifndef NATIVE_OBJC_INSTANCETYPE
+typedef id instancetype;
+#endif
+
+
 /* ==========================================================================
 
    NSColor, EmacsColor category.
@@ -1302,6 +1299,11 @@ extern char gnustep_base_version[];  /* version tracking */
 #define NSWindowStyleMaskUtilityWindow     NSUtilityWindowMask
 #define NSAlertStyleCritical               NSCriticalAlertStyle
 #define NSControlSizeRegular               NSRegularControlSize
+
+/* And adds NSWindowStyleMask. */
+#ifdef __OBJC__
+typedef NSUInteger NSWindowStyleMask;
+#endif
 #endif
 
 #endif	/* HAVE_NS */
-- 

Looks like this does the trick. Thanks Noam!

Charles, could you confirm this patch builds on 10.6?

-- 
Alan Third




This bug report was last modified 7 years and 358 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.