gh-121647: Define _Py_TYPEOF macro on more compilers#121648
gh-121647: Define _Py_TYPEOF macro on more compilers#121648fuhsnn wants to merge 1 commit intopython:mainfrom
Conversation
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.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Hello! Sorry for the delay in reviewing. Ideally, find a way to use Also, I'd prefer not adding the configure check. I don't see much benefit over |
|
Thanks for reviewing, I did the PR to see if it gets a better chance than #121643, however cpython has grown to requiring more patches ( On C23 |
|
Thanks. |
|
Just tested 3.15 master (default and --disable-gil), in addition to #134070 these are enough for slimcc to pass all tests (sans test_gdb, probably caused by lacking DWARF info). diff --git a/Include/internal/pycore_debug_offsets.h b/Include/internal/pycore_debug_offsets.h
index 66f14e6..fbdc40a 100644
--- a/Include/internal/pycore_debug_offsets.h
+++ b/Include/internal/pycore_debug_offsets.h
@@ -41,7 +41,7 @@ extern "C" {
#define _GENERATE_DEBUG_SECTION_APPLE(name)
#endif
-#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__))
+#if defined(__linux__) && (defined(__GNUC__) || defined(__clang__) || (_Py__has_attribute(section) && _Py__has_attribute(used)))
#define _GENERATE_DEBUG_SECTION_LINUX(name) \
__attribute__((section("." Py_STRINGIFY(name)))) \
__attribute__((used))
diff --git a/Objects/mimalloc/init.c b/Objects/mimalloc/init.c
index 81b2410..3856a10 100644
--- a/Objects/mimalloc/init.c
+++ b/Objects/mimalloc/init.c
@@ -676,7 +676,7 @@ static void mi_cdecl mi_process_done(void) {
}
static bool mi_initialized = _mi_process_init();
-#elif defined(__GNUC__) || defined(__clang__)
+#elif defined(__GNUC__) || defined(__clang__) || _Py__has_attribute(constructor)
// GCC,Clang: use the constructor attribute |
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.
_Py_TYPEOFon MSVC and other compilers supporting__typeof__#121647