extern-inline.m4 3.4 KB

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