FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-121647: Define _Py_TYPEOF macro on more compilers by fuhsnn · Pull Request #121648 · python/cpython · GitHub

/ cpython Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ac  (1) .h  (1) .in  (1) No extension  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 7 additions & 2 deletions Include/pyport.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,14 @@ extern "C" {
//
// Example: _Py_TYPEOF(x) x_copy = (x);
//
// The macro is only defined if GCC or clang compiler is used.
#if defined(__GNUC__) || defined(__clang__)
// Defined if __typeof__ or its equivalents are available.
#if defined(__GNUC__) || defined(__clang__) || defined(HAVE_TYPEOF) || \
(defined(_MSC_VER) && _MSC_VER >= 1939)
# define _Py_TYPEOF(expr) __typeof__(expr)
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
# define _Py_TYPEOF(expr) typeof(expr)
#elif defined(__cplusplus) && __cplusplus >= 201103
# define _Py_TYPEOF(expr) decltype(expr)
#endif


Expand Down
30 changes: 30 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions configure.ac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6983,6 +6983,19 @@ case "$ac_cv_computed_gotos" in yes*)
[Define if the C compiler supports computed gotos.])
esac

AC_CACHE_CHECK([whether $CC supports __typeof__], [ac_cv_typeof],
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
int i;
__typeof__(i) *p = &i;
]])],
[ac_cv_typeof=yes],
[ac_cv_typeof=no]))
if test "$ac_cv_typeof" = yes
then
AC_DEFINE([HAVE_TYPEOF], [1],
[Define if the C compiler supports __typeof__(expr)])
fi

case $ac_sys_system in
AIX*)
AC_DEFINE([HAVE_BROKEN_PIPE_BUF], [1],
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,9 @@
/* Define to 1 if you have the `ttyname' function. */
#undef HAVE_TTYNAME

/* Define if the C compiler supports __typeof__(expr) */
#undef HAVE_TYPEOF

/* Define to 1 if you don't have `tm_zone' but do have the external array
`tzname'. */
#undef HAVE_TZNAME
Expand Down

Back | FazBrowse Home | New Git URL