summaryrefslogtreecommitdiffstats
path: root/Include/pymacro.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-04-21 14:40:34 (GMT)
committerGitHub <noreply@github.com>2022-04-21 14:40:34 (GMT)
commit1b184c84082530f35c593cb7728752e258371c30 (patch)
treeb8608f7aaa90615e33077639dfe092c8fcbfc229 /Include/pymacro.h
parent1a2b282f201073d5153e737568c833af6f1b349e (diff)
downloadcpython-1b184c84082530f35c593cb7728752e258371c30.zip
cpython-1b184c84082530f35c593cb7728752e258371c30.tar.gz
cpython-1b184c84082530f35c593cb7728752e258371c30.tar.bz2
gh-91782: Define static_assert() macro on FreeBSD (#91787)
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
Diffstat (limited to 'Include/pymacro.h')
-rw-r--r--Include/pymacro.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h
index 2728496..71d6714 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -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))