autoconf: modernize and modularize
[tftp-hpa.git] / autoconf / m4 / pa_c_typeof.m4
blob909b1712e3f529b16f0be45fb28def0fe387763f
1 dnl --------------------------------------------------------------------------
2 dnl PA_C_TYPEOF
3 dnl
4 dnl Find if typeof() exists, or an equivalent (__typeof__, decltype,
5 dnl __decltype__)
6 dnl --------------------------------------------------------------------------
7 AC_DEFUN([PA_C_TYPEOF],
8 [AC_CACHE_CHECK([if $CC supports typeof], [pa_cv_typeof],
9  [pa_cv_typeof=no
10  for pa_typeof_try in typeof __typeof __typeof__ decltype __decltype __decltype__ _Decltype
11  do
12   AS_IF([test $pa_cv_typeof = no],
13         [AC_COMPILE_IFELSE([AC_LANG_SOURCE([
14 AC_INCLUDES_DEFAULT
15 int testme(int x);
16 int testme(int x)
18     $pa_typeof_try(x) y = x*x;
19     return y;
21 ])],
22  [pa_cv_typeof=$pa_typeof_try])])
23  done
24  ])
25  AS_IF([test $pa_cv_typeof = no],
26        [],
27        [AC_DEFINE([HAVE_TYPEOF], 1,
28          [Define to 1 if you have some version of the typeof operator.])
29         AS_IF([test $pa_cv_typeof = typeof],
30               [],
31               [AC_DEFINE_UNQUOTED([typeof], [$pa_cv_typeof],
32                 [Define if your typeof operator is not named `typeof'.])])])])