[Python-checkins] gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559)

pablogsal webhook-mailer at python.org
Mon May 9 13:39:19 EDT 2022


https://github.com/python/cpython/commit/f0614ca9801d0768094570b784d2b26936bcca34
commit: f0614ca9801d0768094570b784d2b26936bcca34
branch: main
author: Pablo Galindo Salgado <Pablogsal at gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2022-05-09T18:38:38+01:00
summary:

gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559)

files:
M Include/pymacro.h

diff --git a/Include/pymacro.h b/Include/pymacro.h
index 71d6714afd112..5037bbd013801 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -10,6 +10,14 @@
 #  define static_assert _Static_assert
 #endif
 
+// static_assert is defined in GLIB from version 2.16. Before it requires
+// compiler support (gcc >= 4.6) and is called _Static_assert.
+#if (defined(__GLIBC__) \
+     && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 16)) \
+     && !defined(static_assert))
+#  define static_assert _Static_assert
+#endif
+
 /* Minimum value between x and y */
 #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))
 



More information about the Python-checkins mailing list