[m-rev.] diff: fix compilation of the runtime with GCC in C99 mode

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jan 5 00:55:36 AEDT 2012


Branches: main, 11.07

Fix a problem with the runtime when using GCC in C99 mode.

runtime/mercury_std.h:
 	GCC uses the C99 semantics for inline functions when
 	it is in C99 mode, we need to too.

Julien.

Index: runtime/mercury_std.h
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_std.h,v
retrieving revision 1.37
diff -u -r1.37 mercury_std.h
--- runtime/mercury_std.h	12 Nov 2011 04:51:17 -0000	1.37
+++ runtime/mercury_std.h	4 Jan 2012 13:45:59 -0000
@@ -171,11 +171,23 @@
    #define MR_EXTERN_INLINE		static
    #define MR_OUTLINE_DEFN(DECL,BODY)
  #elif defined(MR_GNUC) 
-  /* GNU C */
-  #define MR_STATIC_INLINE		static __inline__
-  #define MR_INLINE			static __inline__
-  #define MR_EXTERN_INLINE		extern __inline__
-  #define MR_OUTLINE_DEFN(DECL,BODY)	DECL BODY
+  /* GNU C: in (GNU) C99 or later mode GCC will use C99 style
+  ** inline functions; otherwise GNU style inline functions will
+  ** will be used.
+  */
+  #if defined(__GNUC_STDC_INLINE__)
+    /* C99 style inlining. */
+    #define MR_STATIC_INLINE		static inline
+    #define MR_INLINE			static inline
+    #define MR_EXTERN_INLINE		inline
+    #define MR_OUTLINE_DEFN(DECL,BODY)	extern DECL;
+  #else
+    /* GNU C90 style inlining. */
+    #define MR_STATIC_INLINE		static __inline__
+    #define MR_INLINE			static __inline__
+    #define MR_EXTERN_INLINE		extern __inline__
+    #define MR_OUTLINE_DEFN(DECL,BODY)	DECL BODY
+  #endif /* ! __GNUC_STDC_INLINE */
  #elif defined(MR_MSVC)
    #define MR_STATIC_INLINE              static __inline
    #define MR_INLINE                     static __inline

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list