Skip to content

Commit fdff1f0

Browse files
author
ripley
committed
check if an enum can set its underlying type
git-svn-id: https://svn.r-project.org/R/trunk@87765 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent e1ec7ab commit fdff1f0

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

configure

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49635,6 +49635,51 @@ printf "%s\n" "#define HAVE_WORKING_SIGACTION 1" >>confdefs.h
4963549635
fi
4963649636

4963749637

49638+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the base type of an enum can be specified" >&5
49639+
printf %s "checking whether the base type of an enum can be specified... " >&6; }
49640+
if test ${r_cv_enum_type+y}
49641+
then :
49642+
printf %s "(cached) " >&6
49643+
else case e in #(
49644+
e) if test "$cross_compiling" = yes
49645+
then :
49646+
r_cv_enum_type=no
49647+
else case e in #(
49648+
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
49649+
/* end confdefs.h. */
49650+
49651+
49652+
typedef enum :int { FALSE = 0, TRUE } Rboolean;
49653+
49654+
int main(void) {
49655+
return 0;
49656+
}
49657+
49658+
49659+
_ACEOF
49660+
if ac_fn_c_try_run "$LINENO"
49661+
then :
49662+
r_cv_enum_type=yes
49663+
else case e in #(
49664+
e) r_cv_enum_type=no ;;
49665+
esac
49666+
fi
49667+
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
49668+
conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
49669+
esac
49670+
fi
49671+
;;
49672+
esac
49673+
fi
49674+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $r_cv_enum_type" >&5
49675+
printf "%s\n" "$r_cv_enum_type" >&6; }
49676+
if test "x${r_cv_enum_type}" = xyes; then
49677+
49678+
printf "%s\n" "#define HAVE_ENUM_BASE_TYPE 1" >>confdefs.h
49679+
49680+
fi
49681+
49682+
4963849683
if test x${use_internal_tzcode} = xdefault; then
4963949684
case "${host_os}" in
4964049685
darwin*)

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,11 @@ R_FUNC_LOG1P
22732273
R_FUNC_FTELL
22742274
R_FUNC_SIGACTION
22752275

2276+
dnl setting the size of an 'enum' is a C23 addition,
2277+
dnl also supported in some versions of clang.
2278+
dnl GCC only supports it in a C23 mode.
2279+
R_ENUM_BASE_TYPE
2280+
22762281
if test x${use_internal_tzcode} = xdefault; then
22772282
case "${host_os}" in
22782283
darwin*)

m4/R.m4

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,6 +5437,25 @@ int main(void) {
54375437
[r_cv_C99=no])])
54385438
])# R_C90
54395439

5440+
AC_DEFUN([R_ENUM_BASE_TYPE],
5441+
[AC_CACHE_CHECK([whether the base type of an enum can be specified], [r_cv_enum_type],
5442+
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
5443+
5444+
typedef enum :int { FALSE = 0, TRUE } Rboolean;
5445+
5446+
int main(void) {
5447+
return 0;
5448+
}
5449+
5450+
]])],
5451+
[r_cv_enum_type=yes],
5452+
[r_cv_enum_type=no],
5453+
[r_cv_enum_type=no])])
5454+
if test "x${r_cv_enum_type}" = xyes; then
5455+
AC_DEFINE(HAVE_ENUM_BASE_TYPE, 1, [Define if enum can set its base type.])
5456+
fi
5457+
])# R_ENUM_BASE_TYPE
5458+
54405459
### Local variables: ***
54415460
### mode: outline-minor ***
54425461
### outline-regexp: "### [*]+" ***

src/gnuwin32/fixed/h/config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@
278278
/* Define to 1 if you have the <elf.h> header file. */
279279
/* #undef HAVE_ELF_H */
280280

281+
/* Define if enum can set its base type. */
282+
#define HAVE_ENUM_BASE_TYPE 1
283+
281284
/* Define to 1 if you have the <errno.h> header file. */
282285
#define HAVE_ERRNO_H 1
283286

src/include/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@
263263
/* Define to 1 if you have the <elf.h> header file. */
264264
#undef HAVE_ELF_H
265265

266+
/* Define if enum can set its base type. */
267+
#undef HAVE_ENUM_BASE_TYPE
268+
266269
/* Define to 1 if you have the <errno.h> header file. */
267270
#undef HAVE_ERRNO_H
268271

0 commit comments

Comments
 (0)