| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
# Check whether C23 auto is supported by the current compiler and compilation |
| 5 |
# flags. If not, but the GNU __auto_type extension is supported, define auto to |
| 6 |
# __auto_type. Otherwise, fail. |
| 7 |
AC_DEFUN([MY_C_AUTO], |
| 8 |
[AC_CACHE_CHECK([for auto], [my_cv_c_auto], |
| 9 |
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[auto x = 1;]])], |
| 10 |
[my_cv_c_auto=yes], [my_cv_c_auto=no])]) |
| 11 |
if test "x$my_cv_c_auto" != xyes; then |
| 12 |
AC_CACHE_CHECK([for __auto_type], [my_cv_c___auto_type], |
| 13 |
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[__auto_type x = 1;]])], |
| 14 |
[my_cv_c___auto_type=yes], [my_cv_c___auto_type=no])]) |
| 15 |
if test "x$my_cv_c___auto_type" = xyes; then |
| 16 |
AC_DEFINE([auto], [__auto_type]) |
| 17 |
else |
| 18 |
AC_MSG_ERROR([no auto or __auto_type]) |
| 19 |
fi |
| 20 |
fi |
| 21 |
]) |