1 dnl 'extern inline' a la ISO C99.
3 dnl Copyright 2012-2015 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_EXTERN_INLINE],
10 AH_VERBATIM([extern_inline],
11 [/* Please see the Gnulib manual for how to use these macros.
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
16 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
22 Suppress the use of extern inline on problematic Apple configurations.
23 OS X 10.8 and earlier mishandle it; see, e.g.,
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
25 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
26 for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
27 Perhaps Apple will fix this some day. */
28 #if (defined __APPLE__ \
29 && (defined __header_inline \
30 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
31 && ! defined __clang__) \
32 : ((! defined _DONT_USE_CTYPE_INLINE_ \
33 && (defined __GNUC__ || defined __cplusplus)) \
34 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
35 && defined __GNUC__ && ! defined __cplusplus))))
36 # define _GL_EXTERN_INLINE_APPLE_BUG
39 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
40 : (199901L <= __STDC_VERSION__ \
42 && !(defined __SUNPRO_C && __STDC__))) \
43 && !defined _GL_EXTERN_INLINE_APPLE_BUG)
44 # define _GL_INLINE inline
45 # define _GL_EXTERN_INLINE extern inline
46 # define _GL_EXTERN_INLINE_IN_USE
47 #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
48 && !defined _GL_EXTERN_INLINE_APPLE_BUG)
49 # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
50 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
51 # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
53 # define _GL_INLINE extern inline
55 # define _GL_EXTERN_INLINE extern
56 # define _GL_EXTERN_INLINE_IN_USE
58 # define _GL_INLINE static _GL_UNUSED
59 # define _GL_EXTERN_INLINE static _GL_UNUSED
62 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
63 # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
64 # define _GL_INLINE_HEADER_CONST_PRAGMA
66 # define _GL_INLINE_HEADER_CONST_PRAGMA \
67 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
69 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
70 and "no previous declaration for 'FOO'" diagnostics,
71 when FOO is an inline function in the header; see
72 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
73 # define _GL_INLINE_HEADER_BEGIN \
74 _Pragma ("GCC diagnostic push") \
75 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
76 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
77 _GL_INLINE_HEADER_CONST_PRAGMA
78 # define _GL_INLINE_HEADER_END \
79 _Pragma ("GCC diagnostic pop")
81 # define _GL_INLINE_HEADER_BEGIN
82 # define _GL_INLINE_HEADER_END