gh-121647: Define _Py_TYPEOF macro on more compilers · python/cpython@85e5cbd · GitHub
Skip to content

Commit 85e5cbd

Browse files
committed
gh-121647: Define _Py_TYPEOF macro on more compilers
Extend the _Py_TYPEOF macro to more implementations of __typeof__ and standardized equivalents on C23 and C++11. On MSVC, __typeof__ is enabled through _MSC_VER check; for others, an autoconf probe is implemented.
1 parent 65feded commit 85e5cbd

4 files changed

Lines changed: 53 additions & 2 deletions

File tree

Include/pyport.h

Lines changed: 7 additions & 2 deletions

configure

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6983,6 +6983,19 @@ case "$ac_cv_computed_gotos" in yes*)
69836983
[Define if the C compiler supports computed gotos.])
69846984
esac
69856985

6986+
AC_CACHE_CHECK([whether $CC supports __typeof__], [ac_cv_typeof],
6987+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
6988+
int i;
6989+
__typeof__(i) *p = &i;
6990+
]])],
6991+
[ac_cv_typeof=yes],
6992+
[ac_cv_typeof=no]))
6993+
if test "$ac_cv_typeof" = yes
6994+
then
6995+
AC_DEFINE([HAVE_TYPEOF], [1],
6996+
[Define if the C compiler supports __typeof__(expr)])
6997+
fi
6998+
69866999
case $ac_sys_system in
69877000
AIX*)
69887001
AC_DEFINE([HAVE_BROKEN_PIPE_BUF], [1],

pyconfig.h.in

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)