Commit | Line | Data |
---|---|---|
a0d4efe9 PE |
1 | dnl 'extern inline' a la ISO C99. |
2 | ||
ba318903 | 3 | dnl Copyright 2012-2014 Free Software Foundation, Inc. |
a0d4efe9 PE |
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. | |
7 | ||
8 | AC_DEFUN([gl_EXTERN_INLINE], | |
9 | [ | |
a0d4efe9 | 10 | AH_VERBATIM([extern_inline], |
ec9295ae | 11 | [/* Please see the Gnulib manual for how to use these macros. |
904dd565 | 12 | |
89bd9d36 PE |
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>. | |
15 | ||
d9774ea4 PE |
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. | |
21 | ||
220a304a PE |
22 | Suppress the use of extern inline on problematic Apple configurations. |
23 | OS X 10.8 and earlier mishandle it; see, e.g., | |
904dd565 | 24 | <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. |
220a304a PE |
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>. | |
904dd565 | 27 | Perhaps Apple will fix this some day. */ |
230fe2a5 | 28 | #if (defined __APPLE__ \ |
220a304a PE |
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)))) | |
230fe2a5 PE |
36 | # define _GL_EXTERN_INLINE_APPLE_BUG |
37 | #endif | |
904dd565 PE |
38 | #if ((__GNUC__ \ |
39 | ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ | |
d9774ea4 PE |
40 | : (199901L <= __STDC_VERSION__ \ |
41 | && !defined __HP_cc \ | |
42 | && !(defined __SUNPRO_C && __STDC__))) \ | |
230fe2a5 | 43 | && !defined _GL_EXTERN_INLINE_APPLE_BUG) |
a0d4efe9 PE |
44 | # define _GL_INLINE inline |
45 | # define _GL_EXTERN_INLINE extern inline | |
230fe2a5 | 46 | # define _GL_EXTERN_INLINE_IN_USE |
aaea7495 | 47 | #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ |
230fe2a5 | 48 | && !defined _GL_EXTERN_INLINE_APPLE_BUG) |
758bed52 | 49 | # if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ |
01b13eb7 PE |
50 | /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ |
51 | # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) | |
52 | # else | |
53 | # define _GL_INLINE extern inline | |
a0d4efe9 | 54 | # endif |
01b13eb7 | 55 | # define _GL_EXTERN_INLINE extern |
230fe2a5 | 56 | # define _GL_EXTERN_INLINE_IN_USE |
a0d4efe9 | 57 | #else |
904dd565 PE |
58 | # define _GL_INLINE static _GL_UNUSED |
59 | # define _GL_EXTERN_INLINE static _GL_UNUSED | |
a0d4efe9 PE |
60 | #endif |
61 | ||
01b13eb7 | 62 | #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) |
65788e2e | 63 | # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ |
01b13eb7 PE |
64 | # define _GL_INLINE_HEADER_CONST_PRAGMA |
65 | # else | |
66 | # define _GL_INLINE_HEADER_CONST_PRAGMA \ | |
67 | _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") | |
68 | # endif | |
ec9295ae PE |
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>. */ | |
01b13eb7 PE |
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") | |
80 | #else | |
a0d4efe9 PE |
81 | # define _GL_INLINE_HEADER_BEGIN |
82 | # define _GL_INLINE_HEADER_END | |
83 | #endif]) | |
84 | ]) |