extern-inline.m4 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. [/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
  10. _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
  11. _GL_INLINE_HEADER_BEGIN contains useful stuff to put
  12. in an include file, before uses of _GL_INLINE.
  13. It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
  14. when FOO is an inline function in the header; see
  15. <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
  16. _GL_INLINE_HEADER_END contains useful stuff to put
  17. in the same include file, after uses of _GL_INLINE.
  18. Suppress the use of extern inline on Apple's platforms,
  19. as Libc-825.25 (2012-09-19) is incompatible with it; see
  20. <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
  21. Perhaps Apple will fix this some day. */
  22. #if ((__GNUC__ \
  23. ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
  24. : 199901L <= __STDC_VERSION__) \
  25. && !defined __APPLE__)
  26. # define _GL_INLINE inline
  27. # define _GL_EXTERN_INLINE extern inline
  28. #elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__
  29. # if __GNUC_GNU_INLINE__
  30. /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
  31. # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
  32. # else
  33. # define _GL_INLINE extern inline
  34. # endif
  35. # define _GL_EXTERN_INLINE extern
  36. #else
  37. # define _GL_INLINE static _GL_UNUSED
  38. # define _GL_EXTERN_INLINE static _GL_UNUSED
  39. #endif
  40. #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
  41. # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
  42. # define _GL_INLINE_HEADER_CONST_PRAGMA
  43. # else
  44. # define _GL_INLINE_HEADER_CONST_PRAGMA \
  45. _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
  46. # endif
  47. # define _GL_INLINE_HEADER_BEGIN \
  48. _Pragma ("GCC diagnostic push") \
  49. _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
  50. _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
  51. _GL_INLINE_HEADER_CONST_PRAGMA
  52. # define _GL_INLINE_HEADER_END \
  53. _Pragma ("GCC diagnostic pop")
  54. #else
  55. # define _GL_INLINE_HEADER_BEGIN
  56. # define _GL_INLINE_HEADER_END
  57. #endif])
  58. ])