]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91782: Define static_assert() macro on FreeBSD (#91787)
authorVictor Stinner <vstinner@python.org>
Thu, 21 Apr 2022 14:40:34 +0000 (16:40 +0200)
committerGitHub <noreply@github.com>
Thu, 21 Apr 2022 14:40:34 +0000 (16:40 +0200)
On FreeBSD, if the static_assert() macro is not defined, define it in
Python until <sys/cdefs.h> supports C11:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255290

Include/pymacro.h

index 2728496976de7e5ab635906d05e7dc8250cae5da..71d6714afd112c06a35969536d22b715d601de61 100644 (file)
@@ -1,6 +1,15 @@
 #ifndef Py_PYMACRO_H
 #define Py_PYMACRO_H
 
+// gh-91782: On FreeBSD 12, if the _POSIX_C_SOURCE and _XOPEN_SOURCE macros are
+// defined, <sys/cdefs.h> disables C11 support and <assert.h> does not define
+// the static_assert() macro. Define the static_assert() macro in Python until
+// <sys/cdefs.h> suports C11:
+// https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255290
+#if defined(__FreeBSD__) && !defined(static_assert)
+#  define static_assert _Static_assert
+#endif
+
 /* Minimum value between x and y */
 #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))