dzprintf-gnu: Add tests.
[gnulib.git] / m4 / inline.m4
blobf962bde1cc42eb72333699f67095dd2fb5b4790b
1 # inline.m4
2 # serial 4
3 dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc.
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.
8 dnl Test for the 'inline' keyword or equivalent.
9 dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
10 dnl like AC_C_INLINE does.  Also, define HAVE_INLINE if 'inline' or an
11 dnl equivalent is effectively supported, i.e. if the compiler is likely to
12 dnl drop unused 'static inline' functions.
13 AC_DEFUN([gl_INLINE],
15   AC_REQUIRE([AC_C_INLINE])
16   AC_CACHE_CHECK([whether the compiler generally respects inline],
17     [gl_cv_c_inline_effective],
18     [if test $ac_cv_c_inline = no; then
19        gl_cv_c_inline_effective=no
20      else
21        dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
22        dnl specified.
23        dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
24        dnl depends on optimization flags, which can be in CFLAGS.
25        dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
26        AC_COMPILE_IFELSE(
27          [AC_LANG_PROGRAM([[]],
28            [[#ifdef __NO_INLINE__
29                #error "inline is not effective"
30              #endif]])],
31          [gl_cv_c_inline_effective=yes],
32          [gl_cv_c_inline_effective=no])
33      fi
34     ])
35   if test $gl_cv_c_inline_effective = yes; then
36     AC_DEFINE([HAVE_INLINE], [1],
37       [Define to 1 if the compiler supports one of the keywords
38        'inline', '__inline__', '__inline' and effectively inlines
39        functions marked as such.])
40   fi