Skip to content

Commit f0ddadc

Browse files
committed
Rename Py_BUILD_ASSERT to Py_BUILD_ASSERT_EXPR
To make it clearer that Py_BUILD_ASSERT_EXPR(cond) cannot be used as assert(cond).
1 parent 573696a commit f0ddadc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Include/pymacro.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,26 @@
1717
1818
#define foo_to_char(foo) \
1919
((char *)(foo) \
20-
+ Py_BUILD_ASSERT(offsetof(struct foo, string) == 0))
20+
+ Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0))
2121
2222
Written by Rusty Russell, public domain, http://ccodearchive.net/ */
23-
#define Py_BUILD_ASSERT(cond) \
23+
#define Py_BUILD_ASSERT_EXPR(cond) \
2424
(sizeof(char [1 - 2*!(cond)]) - 1)
2525

26-
2726
/* Get the number of elements in a visible array
2827
2928
This does not work on pointers, or arrays declared as [], or function
3029
parameters. With correct compiler support, such usage will cause a build
31-
error (see Py_BUILD_ASSERT).
30+
error (see Py_BUILD_ASSERT_EXPR).
3231
3332
Written by Rusty Russell, public domain, http://ccodearchive.net/ */
3433
#if defined(__GNUC__)
3534
/* Two gcc extensions.
3635
&a[0] degrades to a pointer: a different type from an array */
3736
#define Py_ARRAY_LENGTH(array) \
3837
(sizeof(array) / sizeof((array)[0]) \
39-
+ Py_BUILD_ASSERT(!__builtin_types_compatible_p(typeof(array), \
40-
typeof(&(array)[0]))))
38+
+ Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \
39+
typeof(&(array)[0]))))
4140
#else
4241
#define Py_ARRAY_LENGTH(array) \
4342
(sizeof(array) / sizeof((array)[0]))

0 commit comments

Comments
 (0)