1dnl 'extern inline' a la ISO C99. 2 3dnl Copyright 2012-2022 Free Software Foundation, Inc. 4dnl This file is free software; the Free Software Foundation 5dnl gives unlimited permission to copy and/or distribute it, 6dnl with or without modifications, as long as this notice is preserved. 7 8AC_DEFUN([gl_EXTERN_INLINE], 9[ 10 AC_CACHE_CHECK([whether ctype.h defines __header_inline], 11 [gl_cv_have___header_inline], 12 [AC_PREPROC_IFELSE( 13 [AC_LANG_SOURCE([[#include <ctype.h> 14 #ifndef __header_inline 15 #error "<ctype.h> does not define __header_inline" 16 #endif 17 ]])], 18 [gl_cv_have___header_inline=yes], 19 [gl_cv_have___header_inline=no])]) 20 if test "$gl_cv_have___header_inline" = yes; then 21 AC_DEFINE([HAVE___HEADER_INLINE], [1], 22 [Define to 1 if ctype.h defines __header_inline.]) 23 fi 24 25 AH_VERBATIM([HAVE___HEADER_INLINE_1], 26[/* Please see the Gnulib manual for how to use these macros. 27 28 Suppress extern inline with HP-UX cc, as it appears to be broken; see 29 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>. 30 31 Suppress extern inline with Sun C in standards-conformance mode, as it 32 mishandles inline functions that call each other. E.g., for 'inline void f 33 (void) { } inline void g (void) { f (); }', c99 incorrectly complains 34 'reference to static identifier "f" in extern inline function'. 35 This bug was observed with Oracle Developer Studio 12.6 36 (Sun C 5.15 SunOS_sparc 2017/05/30). 37 38 Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) 39 on configurations that mistakenly use 'static inline' to implement 40 functions or macros in standard C headers like <ctype.h>. For example, 41 if isdigit is mistakenly implemented via a static inline function, 42 a program containing an extern inline function that calls isdigit 43 may not work since the C standard prohibits extern inline functions 44 from calling static functions (ISO C 99 section 6.7.4.(3). 45 This bug is known to occur on: 46 47 OS X 10.8 and earlier; see: 48 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html 49 50 DragonFly; see 51 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log 52 53 FreeBSD; see: 54 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html 55 56 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and 57 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>. 58 Assume DragonFly and FreeBSD will be similar. 59 60 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 61 inline semantics, unless -fgnu89-inline is used. It defines a macro 62 __GNUC_STDC_INLINE__ to indicate this situation or a macro 63 __GNUC_GNU_INLINE__ to indicate the opposite situation. 64 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline 65 semantics but warns, unless -fgnu89-inline is used: 66 warning: C99 inline functions are not supported; using GNU89 67 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute 68 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. 69 */ 70#if (((defined __APPLE__ && defined __MACH__) \ 71 || defined __DragonFly__ || defined __FreeBSD__) \ 72 && (defined HAVE___HEADER_INLINE \ 73 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ 74 && ! defined __clang__) \ 75 : ((! defined _DONT_USE_CTYPE_INLINE_ \ 76 && (defined __GNUC__ || defined __cplusplus)) \ 77 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ 78 && defined __GNUC__ && ! defined __cplusplus)))) 79# define _GL_EXTERN_INLINE_STDHEADER_BUG 80#endif 81#if ((__GNUC__ \ 82 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 83 : (199901L <= __STDC_VERSION__ \ 84 && !defined __HP_cc \ 85 && !defined __PGI \ 86 && !(defined __SUNPRO_C && __STDC__))) \ 87 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) 88# define _GL_INLINE inline 89# define _GL_EXTERN_INLINE extern inline 90# define _GL_EXTERN_INLINE_IN_USE 91#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 92 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) 93# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ 94 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 95# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) 96# else 97# define _GL_INLINE extern inline 98# endif 99# define _GL_EXTERN_INLINE extern 100# define _GL_EXTERN_INLINE_IN_USE 101#else 102# define _GL_INLINE _GL_UNUSED static 103# define _GL_EXTERN_INLINE _GL_UNUSED static 104#endif 105 106/* In GCC 4.6 (inclusive) to 5.1 (exclusive), 107 suppress bogus "no previous prototype for 'FOO'" 108 and "no previous declaration for 'FOO'" diagnostics, 109 when FOO is an inline function in the header; see 110 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and 111 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */ 112#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ 113# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 114# define _GL_INLINE_HEADER_CONST_PRAGMA 115# else 116# define _GL_INLINE_HEADER_CONST_PRAGMA \ 117 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 118# endif 119# define _GL_INLINE_HEADER_BEGIN \ 120 _Pragma ("GCC diagnostic push") \ 121 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ 122 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ 123 _GL_INLINE_HEADER_CONST_PRAGMA 124# define _GL_INLINE_HEADER_END \ 125 _Pragma ("GCC diagnostic pop") 126#else 127# define _GL_INLINE_HEADER_BEGIN 128# define _GL_INLINE_HEADER_END 129#endif]) 130]) 131