]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559) (#92566)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 9 May 2022 19:35:42 +0000 (12:35 -0700)
committerGitHub <noreply@github.com>
Mon, 9 May 2022 19:35:42 +0000 (20:35 +0100)
(cherry picked from commit f0614ca9801d0768094570b784d2b26936bcca34)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Include/pymacro.h

index 71d6714afd112c06a35969536d22b715d601de61..5037bbd013801b9e868990cf3bb913552edd5024 100644 (file)
 #  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))