From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 9 May 2022 19:35:42 +0000 (-0700) Subject: gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559) (#92566) X-Git-Tag: v3.11.0b2~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=57ff4984e66673ee8bc1534063b591a3b9450e94;p=thirdparty%2FPython%2Fcpython.git gh-91731: Add macro compatibility for static_assert for old libcs (GH-92559) (#92566) (cherry picked from commit f0614ca9801d0768094570b784d2b26936bcca34) Co-authored-by: Pablo Galindo Salgado Co-authored-by: Pablo Galindo Salgado --- diff --git a/Include/pymacro.h b/Include/pymacro.h index 71d6714afd11..5037bbd01380 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))