bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdarg: don't put compiler in gnu99 mode by default


From: Bruno Haible
Subject: Re: stdarg: don't put compiler in gnu99 mode by default
Date: Sat, 12 Apr 2008 04:07:05 +0200
User-agent: KMail/1.5.4

Hi gmp maintainers,

The #ifdefs for determining which variant of 'inline' or 'extern inline'
don't work any more with the Apple GCC compiler on MacOS X.

See the threads that started in
  http://lists.gnu.org/archive/html/bug-gnulib/2008-04/msg00103.html
  http://lists.gnu.org/archive/html/bug-gnulib/2008-04/msg00079.html

Ludovic Courtès wrote:
> > + #ifdef __GNUC_STDC_INLINE__
> > + #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ 
> > ((__gnu_inline__))
> 
> Unfortunately that doesn't work on MacOS X because Apple's GCC (labeled
> "4.0") implements C99 inline semantics but
> 
>   1. Does not define `__GNUC_STDC_INLINE__'.
>   2. Does not support `__gnu_inline__'.

Right. We have looked at Apple GCC version 4.0.1 build 5465 (the one used
for MacOS X 10.5.*) and 5479 (a further development).

  - They implement 'inline' with ISO C99 semantics when -std=c99 or -std=gnu99
    is specified (like GCC >= 4.3).
  - They warn about an ignored attribute if __attribute__((__gnu_inline__))
    is used (like GCC < 4.2).
  - Build 5479 defines __GNUC_STDC_INLINE__ or __GNUC_GNU_INLINE__, 
respectively,
    to indicate whether the ISO C99 or the old GCC semantics of 'inline' is in
    effect. Build 5465 does not define these symbols.

The code in gmp-4.2.2 has two problems:

1) The "#ifdef __GNUC_STDC_INLINE__" test evaluates to true on
   Apple GCC version 4.0.1 build 5479 when std=c99 or -std=gnu99 is specified,
   but __attribute__ ((__gnu_inline__)) is unsupported in this case.
2) The "#else" test evaluates to true test evaluates to true on
   Apple GCC version 4.0.1 build 5465 when std=c99 or -std=gnu99 is specified,
   but 'extern __inline__' uses the ISO C99 semantics, not the old GCC
   semantics in this case.

Here is a suggested fix.  The only part I'm not sure about is whether
__GMP_INLINE_PROTOTYPES should be defined or not when __GMP_EXTERN_INLINE
is not defined.


2008-04-11  Bruno Haible  <address@hidden>

        * gmp-h.in (__GMP_EXTERN_INLINE): Adjust conditions to work also for
        Apple MacOS X compilers.
        Reported by Ludovic Courtès <address@hidden> and
        Peter O'Gorman <address@hidden>.

--- gmp-h.in.bak        2007-09-03 18:05:40.000000000 +0200
+++ gmp-h.in    2008-04-12 03:46:18.000000000 +0200
@@ -1,7 +1,7 @@
 /* Definitions for GNU multiple precision functions.   -*- mode: c -*-
 
 Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -418,15 +418,23 @@
     for an inline too, so as to correctly specify "dllimport" on windows, in
     case the function is called rather than inlined.
     GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
-    inline semantics, unless -fgnu89-inline is used.  */
+    inline semantics, unless -fgnu89-inline is used.
+    GCC 4.2 and above support __inline__ __attribute__ ((__gnu_inline__))
+    to designate the old GCC inline semantics.
+    Apple CC 4.0.1 build 5465 with -std=c99 or -std=gnu99 implements ISO C99
+    inline semantics, but does not set __GNUC_STDC_INLINE__.
+    Apple CC 4.0.1 build 5465 or later, without -std=c99 or -std=gnu99,
+    implements the old GCC inline semantics.  Build 5479 sets
+    __GNUC_GNU_INLINE__, build 5465 does not.  */
 #ifdef __GNUC__
-#ifdef __GNUC_STDC_INLINE__
+#ifdef __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
 #define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))
-#else
+#define __GMP_INLINE_PROTOTYPES  1
+#elif !(defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && 
__STDC_VERSION__ >= 199901L)
 #define __GMP_EXTERN_INLINE      extern __inline__
-#endif
 #define __GMP_INLINE_PROTOTYPES  1
 #endif
+#endif
 
 /* DEC C (eg. version 5.9) supports "static __inline foo()", even in -std1
    strict ANSI mode.  Inlining is done even when not optimizing (ie. -O0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]