|
199 | 199 | } while(0) |
200 | 200 | #endif |
201 | 201 |
|
202 | | -/* Get the number of elements in a visible array |
203 | | -
|
204 | | - This does not work on pointers, or arrays declared as [], or function |
205 | | - parameters. With correct compiler support, such usage will cause a build |
206 | | - error (see Py_BUILD_ASSERT_EXPR). |
207 | | -
|
208 | | - Written by Rusty Russell, public domain, http://ccodearchive.net/ |
209 | | -
|
210 | | - Requires at GCC 3.1+ */ |
211 | | -#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ |
212 | | - (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) || (__GNUC__ >= 4))) |
213 | | -/* Two gcc extensions. |
214 | | - &a[0] degrades to a pointer: a different type from an array */ |
| 202 | +// Get the number of elements in a visible array. |
| 203 | +// |
| 204 | +// This does not work on pointers, or arrays declared as [], or function |
| 205 | +// parameters. With correct compiler support, such usage will cause a build |
| 206 | +// error (see Py_BUILD_ASSERT_EXPR). |
| 207 | +// |
| 208 | +// Written by Rusty Russell, public domain, http://ccodearchive.net/ |
| 209 | +// |
| 210 | +// Require GCC 4 (it works on GCC 3.1). |
| 211 | +// |
| 212 | +// Two GCC extensions: &a[0] degrades to a pointer, a different type from an |
| 213 | +// array. |
| 214 | +// |
| 215 | +// gh-158810: Do not use __builtin_types_compatible_p() in strict C ANSI mode |
| 216 | +// and on C++. |
| 217 | +#if (defined(__GNUC__) && __GNUC__ >= 4 \ |
| 218 | + && !defined(__STRICT_ANSI__) && !defined(__cplusplus)) |
215 | 219 | #define Py_ARRAY_LENGTH(array) \ |
216 | 220 | (sizeof(array) / sizeof((array)[0]) \ |
217 | 221 | + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \ |
|
0 commit comments