extern-inline.m4 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. dnl 'extern inline' a la ISO C99.
  2. dnl Copyright 2012-2013 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 Apple's platforms, as Libc at least
  18. through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g.,
  19. <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
  20. Perhaps Apple will fix this some day. */
  21. #if ((__GNUC__ \
  22. ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
  23. : (199901L <= __STDC_VERSION__ \
  24. && !defined __HP_cc \
  25. && !(defined __SUNPRO_C && __STDC__))) \
  26. && !defined __APPLE__)
  27. # define _GL_INLINE inline
  28. # define _GL_EXTERN_INLINE extern inline
  29. #elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
  30. && !defined __APPLE__)
  31. # if __GNUC_GNU_INLINE__
  32. /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
  33. # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
  34. # else
  35. # define _GL_INLINE extern inline
  36. # endif
  37. # define _GL_EXTERN_INLINE extern
  38. #else
  39. # define _GL_INLINE static _GL_UNUSED
  40. # define _GL_EXTERN_INLINE static _GL_UNUSED
  41. #endif
  42. #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
  43. # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
  44. # define _GL_INLINE_HEADER_CONST_PRAGMA
  45. # else
  46. # define _GL_INLINE_HEADER_CONST_PRAGMA \
  47. _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
  48. # endif
  49. /* Suppress GCC's bogus "no previous prototype for 'FOO'"
  50. and "no previous declaration for 'FOO'" diagnostics,
  51. when FOO is an inline function in the header; see
  52. <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
  53. # define _GL_INLINE_HEADER_BEGIN \
  54. _Pragma ("GCC diagnostic push") \
  55. _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
  56. _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
  57. _GL_INLINE_HEADER_CONST_PRAGMA
  58. # define _GL_INLINE_HEADER_END \
  59. _Pragma ("GCC diagnostic pop")
  60. #else
  61. # define _GL_INLINE_HEADER_BEGIN
  62. # define _GL_INLINE_HEADER_END
  63. #endif])
  64. ])